Facebook Logout Button for ASP.NET

Facebook Logout Button is used to clear session with Facebook. If a user is logged on Facebook, pressing on the Login Button will result in executing of event handler where additional code can be executed, for example to make logout from that website too.

Facebook Logout Button ASP.NET control is wrapper around Facebook Graph API JavaScript method used for logout and HTML button. With customization of source code, it is possible to create any other element (instead of button) to react on click and do logout, for example, a link or image.

Compiled version and source code version of this ASP.NET control are available in C# and VB.NET programming languages, as part of Facebook Connect ASP.NET control library.




Picture of Facebook Logout Button:

The picture shows the default login button, without any property being set. It is required to set CSS style or class to adapt it to the design of particular website.

bookmarkbutton



Facebook Logout 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 Logout Button demo



Configuration

Configuration of the Facebook Logout Button ASP.NET control is done in ASPX page by setting optional properties and event handler. If dynamic setting of properties is required, they can be also set in the code behind, for example on Page_Load method. If event handler is used, there should be a method in the code behind to execute additional code after a user is logged out (disconnected from Facebook).

There is only one optional event handler which is executed when user is logged out. If the user is already logged out from Facebook, and Logout Button is pressed, event handler is not executed.


Properties:
facebook login button asp.net
Property Name
Type
Description
facebook login button asp.net
Title
String
Title inside Logout Button. Default values is 'Logout'.
facebook login button asp.net
CssClass
String
CSS class of the button.
facebook login button asp.net
CssStyle
String
CssStyle style of the button.


Event Handlers:
facebook login button asp.net
Event Name
Description
facebook login button asp.net
LogoutCalled
Name of protected method that is implemented inside the code behind, and which will be called after logout from Facebook is made.




Usage Examples:

Following examples show usage of Facebook Logout Button ASP.NET control in two ways: default one and the one with all optional properties being set. For second example, C# and VB.NET code is displayed for handling event handler when user is logged out from Facebook.

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 Invite Friends control inside ASP.NET page are highlighted.


Default Logout Button:
 <%@ Page MasterPageFile="~/Master.Master" AutoEventWireup="true" Inherits="FVK_Demo.LogoutButton" %>
 <%@ Register TagPrefix="fvk" TagName="logoutbutton" Src="~/FVK/LogoutButton.ascx" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 <title>Facebook Logout Button for ASP.NET </title>
 <meta name="description" content="ASP.NET Logout Button control for Facebook Connect web sites." />
 </asp:Content>
 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <fvk:logoutbutton ID="logout1" runat="server" />
 </asp:Content>


Logout Button with optional properties and event handler:
 <%@ Page MasterPageFile="~/Master.Master" AutoEventWireup="true" Inherits="FVK_Demo.LogoutButton" %>
 <%@ Register TagPrefix="fvk" TagName="logoutbutton" Src="~/FVK/LogoutButton.ascx" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 <title>Facebook Logout Button for ASP.NET </title>
 <meta name="description" content="ASP.NET Logout Button control for Facebook Connect web sites." />
 </asp:Content>
 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <fvk:logoutbutton ID="logout1" runat="server" 
      OnLogoutCalled="Logout" 
      CssClass="mycssstyle"
      CssStyle="mycssclass"
      Title="Logout Now"
    />
 </asp:Content>


Code behind in C#:
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;
 using Facebook;

 namespace FVK_Demo
 {
    public partial class LogoutButton : System.Web.UI.Page
    {
       protected void Page_Load(object sender, EventArgs e)
       {
            
       }

       protected void Logout(object sender, EventArgs e)
       {
          //Execute some code on logout
       }
    }
 }


Code behind in VB.NET:
 Imports System.Collections.Generic
 Imports System.Linq
 Imports System.Web
 Imports System.Web.UI
 Imports System.Web.UI.WebControls 
 Imports Facebook

 Namespace FVK_Demo
    Public Partial Class LogoutButton
       Inherits System.Web.UI.Page
       Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

       End Sub

       Protected Sub Logout(sender As Object, e As EventArgs)
          'Execute some code on logout
       End Sub
    End Class
 End Namespace

 

Customer Testimonials

"I highly recommend FVK for everybody doing Facebook apps in ASP.NET. In my case it paid it self up in the first hour of use. I was doing my first Facebook project, and had been stuck in resolving problems, rooted in poor documentation and bugs inthe Facebook platform and FDT, and when the deadline was closing in, I was lucky to stumble upon FVK, which enabled me to meet my obligations. I'm also very happy with the quick and flawless service I got from vatlab.com."

Helgi Örn Viggósson, Cofus PLC

Customer Spotlight



Vote for your favorites

Facebook development platform