Download FaceBook Like Button Control (3.63 kb)
After lot of comments and suggestions from my blog readers, I decided to ride on all mighty
FaceBook Like wagon. Yes, I added FaceBook's Like button on my blogs as
well. While implementing this, I decided to make a handy ASP.Net control that I could use
on other ASP.Net web sites as well. So here it is my quick and handy ASP.Net user control that
you can put on your ASP.Net pages.
This implementation generates IFRAME Html tags based on the properties value you assign
to the control. These properties are the same as the ones you select when using FaceBook
user interface to generate Like button.
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 Like button, add reference to this control at top
of your page or control file as show below.
<%@ Register TagPrefix="ByteBlocks" Namespace="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 Like
fbLikeButton.Url = Post.AbsoluteLink.AbsoluteUri;
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.