How to test for true postback

3 posts, 0 answers
  1. Jaime Fuhr
    Jaime Fuhr avatar
    15 posts
    Member since:
    Nov 2009

    Posted 02 Jun 2010 Link to this post

    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. Yana
    Admin
    Yana avatar
    5043 posts

    Posted 04 Jun 2010 Link to this post

    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.
  3. Jaime Fuhr
    Jaime Fuhr avatar
    15 posts
    Member since:
    Nov 2009

    Posted 04 Jun 2010 Link to this post

    Thanks Yana.

    As you had pointed out, I am loading the User Control into the pageview.  So your suggestion works nicely.
Back to Top