This project is read-only.

In individual pages, use fbApplication control?

Apr 5, 2008 at 9:25 PM
Edited Apr 5, 2008 at 9:26 PM

As per the example, my fbApplication control resides in the masterpage. However, lets say i have a page that needs to access user name: if i place an fbApplication in that page (a child page), my application throws an error "Only one allowed". Are we supposed to somehow reference the app in the masterpage from the child page? Just wondering what the correct approach is here.

Apr 5, 2008 at 10:16 PM
Figured it out. Just in case anyone is wondering, you are supposed to do a findcontrol on the masterpage;

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Facebook;
using Facebook.Service;
using Facebook.Web;

public partial class yourClass : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
FacebookApplication fba = (FacebookApplication)Master.FindControl("fbApplication");
FacebookService fbs = new FacebookService(fba.Session);

User user = fbs.Users.GetUser(null, "name");
this.lblQuestionPrompt.Text = user.Name;

Hope this helps someone!
Apr 7, 2008 at 11:51 PM
Also, Nikhil pointed out that you could use the static method GetCurrent like so FacebookApplication.GetCurrent(Page):