Getting MultiFriendSelector to work in C#.NET

Aug 9, 2010 at 8:41 AM
Edited Aug 9, 2010 at 8:47 AM


I'm trying to create a way for people to select friends and send them an invite in C#.NET, but I'm having little luck so far...

I have tried a number of things, the first of which was adding the controls for RequestForm and MultiFriendSelector from the Facebook.Web dll through the Toolbox, but unfortunately this rendered nothing on my page.

The second thing I tried was inserting the html-strings in the code-behind page, but the same thing happened, nothing rendered.

 What I'm trying now is to create the RequestForm and MultiFriendSelector dynamically and inserting them into a div, but the problem I'm having here is that it keeps generating an "Object reference not set to an instance of an object." error.

Here's the code I've written for it:

Facebook.Web.FbmlControls.RequestForm rf = new Facebook.Web.FbmlControls.RequestForm();
rf.Type = "EventDrive Event";
rf.Invite = true;
rf.Method = Facebook.Web.FbmlControls.HttpMethod.Post;
rf.Action = "";
rf.Content = inviteContent();

Facebook.Web.FbmlControls.MultiFriendSelector mfs = new Facebook.Web.FbmlControls.MultiFriendSelector();
mfs.ActionText = "Select Facebook contacts to invite to your event.";
mfs.ShowBorder = true;


This code, as mentioned, keeps generating an "Object reference not set to an instance of an object." error in   rf.TemplateControl.Controls.Add(mfs);   .

 Anyone has any ideas to fix this, or achieve my goal in another way?