views:

239

answers:

2

How do I add a FaceBook 'like' button to my master pages, does it need to be different for each page?

+3  A: 

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.

Gary.Ray
A: 

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

driekwartappel