How to persist data from postbacks with facebook in dotnet

Feb 15, 2008 at 5:19 AM
Edited Feb 15, 2008 at 5:20 AM
Hi, Please help me here.

I have created a page with using facebook components in ASP.NET , I have added multiview control, panels. And i added Gridview controls to the panels and multiview tabs. and i put two buttons.

When page is not postback, the data came fine in gridviews, But when i click on buttons i am losting the data, i put enable view state to true to all controls, still i am not able to mantain data...

please help me in this
Feb 15, 2008 at 8:57 AM

Venkatft wrote:
Hi, Please help me here.

I have created a page with using facebook components in ASP.NET , I have added multiview control, panels. And i added Gridview controls to the panels and multiview tabs. and i put two buttons.

When page is not postback, the data came fine in gridviews, But when i click on buttons i am losting the data, i put enable view state to true to all controls, still i am not able to mantain data...

please help me in this


Thats kind of a broad question. It would be helpful if you'd post the code and then maybe I can help. If you're new to ASP.NET I'd recommend you look at http://www.asp.net/learn/videos/ and browse some of the forums. This is more of a general ASP.NET question and not something with the toolkit.
Feb 15, 2008 at 6:26 PM
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.ObjectModel;

using Facebook.Components;
using Facebook.WebControls;

using SocTel;

using PuddingMedia;

public partial class _Default : CanvasFBMLBasePage
{
private const string FACEBOOKAPIKEY = "d2fe4919105922b313f0e00cdbe02fe4";
private const string FACEBOOK_SECRET = "8b324b8702369636169b72c739b43f00";
protected int Customer_id = 0;
protected DataSet contacts=new DataSet();
Facebook.Entity.User u;
new protected void Page_Load(object sender, EventArgs e)
{
Customer_id = new SocTel.SocTel().login(txtFname.Text, txtLname.Text, txtPassword.Text);
contacts = new SocTel.SocTel().getContactsSorted(Customerid, "identityid");
GridView1.DataSource = contacts;
GridView1.DataBind();

base.Api = FACEBOOKAPIKEY;
base.Secret = FACEBOOK_SECRET;
base.Page_Load(sender, e);
try
{
u = this.FBService.GetUserInfo();
if (!Page.IsPostBack)
{
Panel2.Visible = false;
Panel3.Visible = false;
Panel4.Visible = false;
Panel5.Visible = false;
}
lblValid.Visible = false;
}
catch (Exception)
{
throw;
}
}

protected void btnLogin_Click(object sender, EventArgs e)
{
Customer_id = new SocTel.SocTel().login(txtFname.Text, txtLname.Text, txtPassword.Text);

if (Customer_id != 0)
{
Panel2.Visible = true;
Panel1.Visible = false;
Panel4.Visible = true;
Panel5.Visible = false;
}
else
{
lblValid.Visible = true;
lblValid.Text="Please enter valid login information";
}
}

// Call a phone number (for click to call)
protected void Call(object sender, EventArgs e)
{
lblHelloWorld.Text = "Call from " + FromNumber.Text + " to " + ToNumber.Text;
new SocTel.SocTel().MakeCall2(FromNumber.Text, ToNumber.Text);
}
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Panel3.Visible = true;
Panel4.Visible = false;
Panel5.Visible = false;
}
protected void Button2_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Panel3.Visible = false;
Panel4.Visible = true;
Panel5.Visible = false;
}
protected void Button3_Click(object sender, EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
Panel3.Visible = false;
Panel4.Visible = false;
Panel5.Visible = true;

}
}

So when i am clicking on any button ...i am lossing data from gridview.....
Feb 20, 2008 at 3:39 PM
Are you using a canvas page for facebook if that is the case, then you are loosing session because you are hosting website at a different domain than facebook. This is a issue related to IE. You can try this code

An easy fix is to add the header in Global.asax:

protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

}

just a thought
Feb 20, 2008 at 5:49 PM
Hi

I got the solution, for my problem it was connection problem...thanks for your co-operation..

venkat
Apr 30, 2008 at 6:16 AM
Edited Apr 30, 2008 at 6:17 AM
Hi,


I am creating FBApp with the help of asp.net, C#, i have successfully created canvas page and displaying the content also. How to add the tabs in canvas page(Inviting friends)..? Plz anybody can help to resolve this issue.




thanks,
Venkat.B