Rank: Newbie Groups: Member
Joined: 6/16/2018 Posts: 4
|
Question on the tabstrip. I have spent the better part of a day with the Tabstrip control and the Load On Demand Demo that comes with the controls. Everything works until I put something on a page that causes a postback, and then everything on the page disappears.
For example. On page load I can make TabPage1.ascx display the time. But if I put a label on TabPage1.ascx and add a Button1_Click event that displays the time to the label on button1 click, it all just disappears.
What's the secret to content on the tab pages that allows a postback?
Right out of the download, viewstate on the demo is enabled. The Page_load is inside a "if (!IsPostBack)" event. I looked over the documentation for the CallbackPanel. Not seeing anything there.
Thanks,
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
Generally you should not do post back on load on demand unless you are familiar with how ASP.NET works internally. The key for such scenario to work is during post back stage you MUST reconstruct the control tree exactly the same way as before the post back. For example, if there were a button and a label before the post back inside the first tab, you must dynamically recreate these two controls at the exact location (and exact same ID) in the control tree after the post back. Otherwise neither ViewState nor server event will work properly. This is not an issue when you do not dynamically create controls --- because the control tree for both before and after the post back are directly derived from your aspx file, so they are identical. However if you dynamically create controls, then you must ensure these controls are recreated exactly the same fashion during post back.
This does not have anything particular to do with the TabStrip control, it's just how ASP.NET works. You will run into the same issue if you use the standard ASP.NET Panel control as your container. So we won't be able to dive into the details on this. If you still have issues, you can search online and you should be able to find plenty of information on this.
Thanks!
|