Select Facebook Friends for ASP.NET

Select Facebook Friends ASP.NET control is used to provide an easy user interface to get user's friends, and select them for some particular purpose. For example, it can be used in Facebook Gift Application to select friends to whom gift(s) should be sent. On each select, event handler is executed to provide additional action, without the need of press additional buttons to confirm. It can be used to automatically update description of stream publish control or for some similar purpose. The Select Facebook Friends control also has some additional methods to provide filtering and selection from the code behind. There are also properties to configure number of rows and columns of the control. The control has two types of filter methods and three types of selection methods. There is also possibility to change the number of rows and columns. Compiled version and source code version of this ASP.NET control are available in C# and VB.NET programming languages, as part of Facebook ASP.NET (C# and VB.NET) Control library.



Picture of Select Facebook Friends control:

Following picture shows Select Facebook Friends ASP.NET control with 4 rows and 3 columns. Selection of 2 friends is already made.

selectfriends




Select Facebook Friends 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 Select Facebook Friends demo



Configuration

Configuration of the Select Facebook Friends ASP.NET control is done in ASPX page by setting number of rows and columns. If dynamic setting of properties is required, they can be also set in the code behind, for example on Page_Load method. There is also an event handler which executes when selection is changed. If event handler is used, there should be a method in the code behind to execute additional code when the event is triggered. There are also several methods which can be executed on page load, as part of configuration, or later on user action. Following tables show: the list of all properties with their types and descriptions, the list of all methods with input parameters and descriptions, and one event handler.


Properties:
facebook login button asp.net
Property Name
Type
Description
facebook login button asp.net
Rows
Int
Number of rows.
facebook login button asp.net
Columns
Int
Number of columns.


Event Handlers:
facebook login button asp.net
Event Name
Description
facebook login button asp.net
OnSelectionChanged
Name of protected method that is implemented inside the code behind and which will be called after selection is changed.


Methods:
facebook login button asp.net
Method Name
Parameter Type
Description
facebook login button asp.net
SelectAll
void
Make selection on all friends visible in the control - if list of friends are filtered, only filtered friends are selected.
facebook login button asp.net
UnselectAll
void
Unselect all friends.
facebook login button asp.net
FilterByNameStartsWith
String
Filter friends to only those whose name starts with provided parameter.
facebook login button asp.net
FilterByNameContains
String
Filter friends to only those whose name contains provided parameter as sub string.
facebook login button asp.net
GetSelectedFriends
void
Get list of selected friends. Method will return IList of FriendData objects.




Usage Examples:

Following examples show registration and insertion of Select Facebook Friends ASP.NET control in ASPX file. In the code behind, you can see usage of methods for selection, filtering, getting selected friends, and implementation of an event handler in C# and VB.NET programming languages.

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.


ASPX Integration:
 <%@ Page MasterPageFile="~/Components2Master.Master" AutoEventWireup="true" Inherits="FVK_Demo.SelectFriends" %>
 <%@ Register TagPrefix="fvk" TagName="selectfriends" Src="~/FVK/SelectFriends.ascx" %>
 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <fvk:selectfriends id="selectfriends1" runat="server" 
       OnSelectionChanged = "OnSelectedFriends" 
       Rows = "4" 
       Columns = "3" 
    />
 </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.Web;
 using FVK;

 namespace FVK_Demo
 {
    public partial class SelectFriends : Page
    {
       protected void Page_Load(object sender, EventArgs e)
       {
          if (!Page.IsPostBack)
          {
             // get facebook friends whose names starts with 'a'
             selectfriends1.FilterByNameStartsWith("a");

             // get facebook friends whose names cantains 'b' character
             selectfriends1.FilterByNameContains("b");

             // select all filtered friends
             selectfriends1.SelectAll();

             // unselect all filtered friends
             selectfriends1.UnselectAll();
          }
       }

       protected void OnSelectedFriends(object sender, EventArgs e)
       {
          IList selectedFriends = selectfriends1.GetSelectedFriends();
          // do something on change of selection
       }
    }
 }

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.Web
 Imports FVK

 Namespace FVK_Demo
    Public Partial Class SelectFriends
       Inherits Page
       Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
          If Not Page.IsPostBack Then
             ' get facebook friends whose names starts with 'a'
             selectfriends1.FilterByNameStartsWith("a")

             ' get facebook friends whose names cantains 'b' character
             selectfriends1.FilterByNameContains("b")

             ' select all filtered friends
             selectfriends1.SelectAll()

             ' unselect all filtered friends
             selectfriends1.UnselectAll()
          End If
       End Sub

       Protected Sub OnSelectedFriends(sender As Object, e As EventArgs)
          Dim selectedFriends As IList(Of FriendData) = selectfriends1.GetSelectedFriends()
	  ' do something on change of selection
       End Sub
    End Class
 End Namespace

 

Customer Testimonials

"Save time and get your product done faster with this SDK. If you are looking for a solid foundation to build a Facebook Server application, I Highly recommend this SDK and the GiftApp. With extensive code examples and broad Coverage of all things that a typical Facebook app developer needs, you’ll hit the ground running."

Nader Rahimizad, CTO GamesBox Co., Ltd.

Customer Spotlight



Vote for your favorites

Facebook development platform
Contact   |  Refund Policy   |  Privacy Policy   |  EULA