Facebook Like Button for ASP.NET
Facebook Like button is the most important component of the Facebook Graph API. Whole concept about Graph API is based on what people like. Likes make connections from people to other stuff like websites, products, movie, etc. When somebody presses like button on some product, a connection is created from this person to this product. Numerous connections from people to people as friends, and from people to stuffs they like, create a Facebook graph.
Picture of Facebook Like Button: Following picture shows 3 types of like button. From top to bottom, there are: classic Like Button, button count and box count. All other properties for buttons on the picture are default, i.e. they are not set.
Facebook Like Button ASP.NET control has a demo page inside Demo Website that shows how it works. The most important fact is that the Demo website is contained in the package with the library, which is very useful resource for code examples, in both C# and VB.NET, for each control from the library. Look at the Facebook Like Button demo
ConfigurationConfiguration of the Facebook Like Button ASP.NET control is done in ASPX page by setting optional properties. Default like button, which is typically used, does not have any property set. However, customizations are always possible with properties setting. If dynamic setting of properties is required, they can also be set in the code behind, for example on Page_Load method. Following table shows the list of all properties, with their types and descriptions. Properties:
Property Name
Type
Description
Url
String
URL of the like button. If it's not set, current page URL is used.
Layout
String
Layout type. Available values are 'standard', 'button_count', and 'box_count'. Default value is 'standard'.
ShowFaces
Bool
Set to true to show profile pictures of user's friends bellow the like button. Default value is true.
Width
Int
Width of the like button in pixels. Default value is 450.
Action
String
Text of the like button. Available values are 'like' and 'recommend'. It will be translated depending on user's language.
Font
String
Font inside the like button. Available values are 'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', and 'verdana'.
ColorScheme
String
Color scheme. Available values are 'light' and 'dark'. Default value is 'light'.
Reference
String
The reference string for tracking referrals.
Send
String
If set to true, send button will be shown right to the like button.
Usage Examples:Following examples show registration and insertion of Facebook Like Button ASP.NET control in ASPX file. The first example shows default Like Button without any property set. The second example shows Like Button with all properties set. Examples of ASPX files show only the code required for registration and integration of ASP.NET control in a web page. To see all requirements for registered components, including JavaScript, CSS style and header setting, please look at the manual for page requirements. For following examples, all page requirements are placed in ASP.NET master page. Important parts for registration and integration of Facebook Like Button inside ASP.NET page are highlighted. Default Facebook Like Button: <%@ Page MasterPageFile="~/Master.Master" AutoEventWireup="true" Inherits="FVK_Demo.LikeButton" %%> <%@ Register TagPrefix="fvk" TagName="likebutton" Src="~/FVK/LikeButton.ascx" %%> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"%> <title%>Facebook Like Button for ASP.NET</title%> <meta name="description" content="ASP.NET implementation of Facebook Like Button in C# and VB.NET" /%> </asp:Content%> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"%> <fvk:likebutton ID="like1" runat="server" /%> </asp:Content%> Facebook Like Button with all properties set: <%@ Page MasterPageFile="~/Master.Master" AutoEventWireup="true" Inherits="FVK_Demo.LikeButton" %%> <%@ Register TagPrefix="fvk" TagName="likebutton" Src="~/FVK/LikeButton.ascx" %%> <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"%> <title%>Facebook Like Button for ASP.NET</title%> <meta name="description" content="ASP.NET implementation of Facebook Like Button in C# and VB.NET" /%> </asp:Content%> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"%> <fvk:likebutton ID="like1" runat="server" Url="http://vatlab.com" Action="recommend" Font="tahoma" Layout="box_count" SetColorScheme="dark" ShowFaces="false" Width="550" /%> </asp:Content%> |