Facebook Logout Button for ASP.NETFacebook 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. The control is available in C# and VB.NET programming languages, as part of Facebook ASP.NET (C# and VB.NET) Control library.
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.
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
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).
Properties:
Property Name
Type
Description
Title
String
Title inside Logout Button. Default values is 'Logout'.
CssClass
String
CSS class of the button.
CssStyle
String
CssStyle style of the button.
Event Handlers:
Event Name
Description
LogoutCalled
Name of protected method that is implemented inside the code behind, and which will be called after logout from Facebook is made.
|