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
412
Programmatcially selecting a tab in Code Behind
posted

I know this isn't available in the form UltraWebTab1.Tabs(0).Selected = True but thats what I'm trying to get to.  Depending on what an end-user selects I want a certain tab to show up.  I previously read a post on how to use the client side events to do this, something like below...

function gotoGSMtab()
{
var ultraTab = igtab_getTabById('<%=wtService.ClientID %>');
ultraTab.setSelectedIndex(0);
return false;
}

 

I would like to call this from a SelectedIndexChanged of a regular drop down in the code behind, something like this...

        Dim sbc As String = ""

        Select Case tab
            Case "a"
                wtService.Tabs(0).Visible = True
                sbc = "<script type='text/javascript'>"
                sbc = sbc + "var ultraTab = igtab_getTabById('<%=wtService.ClientID %>');"
                sbc = sbc + "ultraTab.setSelectedIndex(0);"
                sbc = sbc + ("</script>")
            Case "b"
                wtService.Tabs(1).Visible = True
                sbc = "<script type='text/javascript'>"
                sbc = sbc + "var ultraTab = igtab_getTabById('<%=wtService.ClientID %>');"
                sbc = sbc + "ultraTab.setSelectedIndex(1);"
                sbc = sbc + ("</script>")
        End Select
        ClientScript.RegisterStartupScript(Me.GetType(), "RM", sbc)

Parents
No Data
Reply
  • 28464
    posted

    So is this approach working or you are having some problems with that? Are you getting any javascript errors in the browser or just nothing happens? The approach seem perfectly valid to me.

    One thing that may be problematic is that ClientScript.RegisterStartupScript places the javascript at the bottom of the page and at this point it might be still too early (tabstrip might not be initialized). There are two possible solutions:

    1. Place the script in a timeout, with say, 200 ms.

    2. Utilize the InitializeTabs event described here - it gets fired at the first moment where it is safe to work with the tab

    http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebTab_Client_Side_Events_CSOM.html

Children