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

Avoid reloading of dynamic pageview on postback

1 Answer 245 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Akhil
Top achievements
Rank 1
Akhil asked on 29 Oct 2015, 07:08 AM

Hi I have a RadTabStrip which has several RadPageView. And I am creating dynamic tabs and pageview for the tabs. Each Pageview has a user control.Within the user control i am rendering a form which is also created dynamically.  My problem is that when an event occurs such as button click (edit/save) on one user control, it again loads all the User controls, since the tabs and pageviews are created dynamically i have to recreate all tabs and pageview again. So, all the user controls loads again.

I just want only one user control to do post back, such as save, while keeping other tabs and pageview intact without reloading it.

Is that possible?​.

 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 03 Nov 2015, 08:13 AM
Hello,

When you add RadTabs and RadPageView's dynamically to the RadTabStrip and the RadMultiPage respectively, they do not need to be recreated on every postback. So you can put the logic responsible for adding them in a if (!IsPostBack) statement, for example:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadTab tab = new RadTab("NewTab");
        RadPageView pageView = new RadPageView();
        pageView.ID = tab.Text + "_pageView";
        tab.PageViewID = pageView.ID;
 
        RadMultiPage1.PageViews.Add(pageView);
        RadTabStrip1.Tabs.Add(tab);
        RadTabStrip1.Tabs.FindTabByText("NewTab").Selected = true;
        RadMultiPage1.PageViews[3].Selected = true;
    }
 
    Control userControl = Page.LoadControl("WebUserControl2.ascx");
    userControl.ID = RadMultiPage1.PageViews[3].ID + "_userControl";
    RadMultiPage1.PageViews[3].Controls.Add(userControl);
}

However, the code for adding the user control is outside the if statement, because unlike Tabs and PageViews when you add user controls dynamically they must be recreated on every postback.

Regards,
Ivan Danchev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Akhil
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or