locked
Javascript Only Runs When TabContainer is Set to OnDemand="False" RRS feed

  • Question

  • User-748031297 posted

    ASP.Net 4.5.  Visual Studio 2012.  IE 11.  Latest (final Ajax Toolkit release).

    I have javascripting that ensures that ListBox controls return to the selected item upon page refresh (instead of scrolling back to the top of the list).  I have placed this code right at the end of the <ContentTemplate> section of a TabPanel (as seen below).  This code runs only if the TabControl is set to OnDemand="False."  I placed an alert('Got here'); at the top of the code to test.  The alert does NOT fire when OnDemand="True."  I want to use OnDemand="True."  Can anyone help me figure out what is needed to make this work?  Thanks for the help.

                    <script type="text/javascript">
                        try {
                            var e = document.getElementById("<%= SelectedChaplains.ClientID %>");
                            e.options[e.selectedIndex].selected = true;
                        }
                        catch (Error) {
                        }
                        try {
                            var e = document.getElementById("<%= RDSelection.ClientID %>");
                            e.options[e.selectedIndex].selected = true;
                        }
                        catch (Error) {
                        }
                        try {
                            var e = document.getElementById("<%= SelectedJurisdictions.ClientID %>");
                     e.options[e.selectedIndex].selected = true;
                        }
                        catch (Error) {
                        }
                    </script>
                </ContentTemplate>
            </cc1:TabPanel>
    

    Is there a way to accomplish my objective in code behind instead of javascript?

    Wednesday, October 22, 2014 1:08 PM

Answers

  • User1918509225 posted

    Hi Chaplain,

    OnDemand in AjaxTabContainer means  Whether to render/load tabs onDemand or all at page load.

    When you set OnDemand as false,it will load all the content in each tab,while if you set OnDemand as true,if it will just load the content which you click the tab.

    So if you when you set the onDemand as false,it will not load the content in the tab if you don't click it. your javascript  function will not work.

    I suggest that you can set a breakpoiny on the javascript ,and press F12 to debug .check if it has any error message.

    Best Regards,

    Kevin Shen.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 23, 2014 2:20 AM