How to use FaceBook Like Button Control?
- Download the source code for the control attached with this post.
- Compile the project and add reference to the project or put compiled assembly in BIN folder of your ASP.Net site.
- On the page where you want to add Likebutton, add reference to this control at top of your page or control file as show below.
<%@ Register TagPrefix="ByteBlocks" Namespace="ByteBlocks.FaceBookWeb" Assembly="ByteBlocks.FaceBookWeb" %>
- Now add control tags on your page as shown below.
<ByteBlocks:FBLikeButton Id="fbLikeButton" runat="server" />
- Now you need to assign the properties for this control to render the button. The most important and required property is Url. This is URL of the page that you want to associate with Like button. Other properties you can ignore because control will pick default values. But without setting Url, there is no Likebutton.
//fbLikeButton.Url = Post.AbsoluteLink.AbsoluteUri; fbLikeButton.Url = "You Facebook Page URL"; fbLikeButton.ShowFaces = false;
You can set these properties in code behind or on the control tag itself.
You can add more options in the control if you like. At the end it is doing nothing more than rendering iframe tag. You can see this control in action on this blog on every single post where you are seeing Like button displayed.
Download location: Here