Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
UltraWebTab LoadOnDemand - only run selected usercontrol?
posted

I wanted to get some clarification on the LoadOnDemand feature of WebTab. When AsyncMode=On and EnableLoadOnDemand=True, it seems that WebTab only returns html for the selected tab as expected. However, when stepping through the code in debug mode, it appears that each usercontrol is still run on the server side with each tab click.

Is there any way to only run the selected usercontrol? I've tried adding usercontrols via the UserControlUrl property as well as manually including the usercontrol in a ContentTemplate. I believe I have a workaround in place, but wanted to make sure I wasn't missing some built-in setting.

<igtab:UltraWebTab ID="tabDevice" runat="server" TabOrientation="LeftTop" BarHeight="0" LoadAllTargetUrls="False" Width="100%" AsyncMode="On" >
   <asyncoptions EnableLoadOnDemand="true"/>
  
<Tabs>
     
<igtab:Tab Text="UC 1" AsyncOption="LoadOnDemand" Key="MyTab1">
        
<ContentPane UserControlUrl="deviceModules/deviceUC.ascx" />
     
</igtab:Tab>
     
<igtab:TabSeparator/>
     
<igtab:Tab Text="UC 2" AsyncOption="LoadOnDemand" Key="MyTab2">
        
<ContentTemplate>
           
<uc1:deviceUC ID="tab2UC" runat="server" />
        
</ContentTemplate>
     
</igtab:Tab>
   </Tabs>
</igtab:UltraWebTab>

Parents
No Data
Reply
  • 24497
    posted

    Hi,

    That is correct, on any postback (full or async) all child controls in all tabs are recreated. Otherwise, viewstate will be lost.

    It is possible to build application which will load a single selected tab. Yes, that will dramatically reduce size of html and speed up application, but that requires so much coding and it will be so potentially buggy, that hardly anybody can go that way.

    Below are approximate steps to implement loading content of only selected tab manually:

    1. <%@ Page ... EnableEventValidation="false" %>
    2. In aspx: remove all child controls from tabs.
    3. Create storage of data of every field which is located in every tab as child control. That storage should contain pairs of ChildField.UniqueID and ChildField.Text (assuming that is TextBox. In case of other more complex controls more work and more complex storage is required). That storage can be Session, database or similar static thing.
    4. Fill that storage on initialization of application (all fields in all tabs).
    5. Create storage of tab index selected in previous postback. For example: Session["oldTab"] = this.UltraWebTab1.SelectedTabIndex;
    6. 
    Process Page.OnLoad (or similar event) and do following
    7. For currently selected tab:
      a) Load content of tab (UserControl or similar).
      b) Save value of currently selected tab (step 5).
      c) Fill values of pairs ChildField.UniqueID and ChildField.Text for fields located in that tab.
      d) Note: Those values (especially UniqueID) will be used after postback to get updated ChildField.Text.
    8. For previously selected tab (tab which has fields modified by user):
      a) To get index of that tab (use value which was saved in step 5)
      b) Use ChildField.UniqueID which was saved in previous postback to get new value from this.Request.Form.
      c) Update value of ChildField.Text in your storage (Session or database) with new value obtained from Form.
      d) If you need to process server events of child controls, then you may check value of __EVENTTARGET in Form. That value should contain UniqueID of control which raised postback. The __EVENTARGUMENT will provide additional information.

Children