This is a migrated thread and some comments may be shown as answers.

How to test for true postback

2 Answers 122 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Jaime Fuhr
Top achievements
Rank 1
Jaime Fuhr asked on 02 Jun 2010, 04:50 PM
We are dynamically loading a RadTabStrip's Multipage with a web user control when the tab is clicked.

The tab contains the user's information that the should be able to change.  For example, email, phone number.

In a normal ASPX page, I would test for IsPostBack = false.  If it is then I pre-load the user's data.  This way, when the user submits their changed data, it is not overwritten by postback doing another data load.

When using the RadTab environment, IsPostBack is always true.  Thus I can't tell if this is a first visit to load the user's data or if they clicked submit.

How can I get around this?

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Jun 2010, 01:35 PM
Hello Jaime,

I suggest you set a custom attribute to the pageview which should indicate whether the user control inside it is loaded for a first time, the attribute can be set when the pageview is created:

if (RadMultiPage1.FindPageViewByID(pageViewID) == null)
{
    RadPageView pageView = new RadPageView();
    pageView.ID = pageViewID;
    pageView.Attributes["loadedUC"] = "0";
    RadMultiPage1.PageViews.Add(pageView);
}

I guess that the user control is loaded in PageViewCreated event handler.

Here is the Page_Load event of the user control which checks the "loadedUC" attribute:

protected void Page_Load(object sender, EventArgs e)
{
   bool firstLoad = false;
   RadPageView parentPageView = (RadPageView)this.Parent;
   if (parentPageView.Attributes["loadedUC"] == "0")
   {
       firstLoad = true;
       parentPageView.Attributes["loadedUC"] = "1";
   }
}


Best regards,
Yana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jaime Fuhr
Top achievements
Rank 1
answered on 04 Jun 2010, 01:55 PM
Thanks Yana.

As you had pointed out, I am loading the User Control into the pageview.  So your suggestion works nicely.
Tags
TabStrip
Asked by
Jaime Fuhr
Top achievements
Rank 1
Answers by
Yana
Telerik team
Jaime Fuhr
Top achievements
Rank 1
Share this question
or