Facebook 'like' button - ASPX Master Pages
-
02-10-2019 - |
Question
How do I add a FaceBook 'like' button to my master pages, does it need to be different for each page?
Solution
Use the Facebook Like Button generator here:
Facebook Like Button Generator
Paste the generated iframe code into your master page. If you leave it as is it will 'like' your site, not specific pages.
To 'like' the individual pages you can take the generated code and look for a section like this:
src="http://www.facebook.com/plugins/like.php?href=mysite.com&
Modify that to read:
src="http://www.facebook.com/plugins/like.php?href=<%=Request.Url.ToString() %>&
And that should work to 'like' each specific page.
OTHER TIPS
You should also add the META property of the generated facebook like button dynamically: use a HtmlGenericControl
in the code behind. I wrote a full article how to add an asp.net like button while using master pages : link text
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow