views:

353

answers:

2

I am creating a CompositeControl in VB ASP.NET.

My control has an Ajax TabContainer with several TabPanels. I need to code it so a value on the querystring can set the container's ActiveTab.

Regardless of the querystring piece of this issue, in my CreateChildControl code, I am setting the ActiveTabIndex to a valid index position, but the UI still has the index 0 as active.

Any tips? Any help?

A: 

Any workaround for this? I have the same problem. Any help appreciated.

Thanks, R.

KRR
I will get the info together. A member on my team fixed this for me, so I'm hoping to get that info online shortly. When I originally wrote this Question, I was thinking we would have to POST back to make it work. He was able to work with the async AJAX way and not POST the entire page.
MADCookie
A: 

For us, specifically, we coded the Javascript needed to get us through this. The displayed page had a TabContainer. On the first tab (the actively displayed tab), we had descriptions of each tab and then a link to them. Clicking the link should make the tab active. Here is what a team member did.

On the hyperlink, added an attribute for "OnClick" to a new JavaScript method we called "ChangeTab". Pass into the method an arbitrary index number to give uniqueness to the different tabs and the tab control's client id

During the ASP.NET's pre render, we have this bit of code

    Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
        MyBase.OnPreRender(e)

        Dim script As New System.Text.StringBuilder()

        script.AppendLine("<script type=""text/javascript"">")
        script.AppendLine("//<![CDATA[ ")
        script.AppendLine("function ChangeTab(num,tabContainer) {")
        script.AppendLine("   var container = $find(tabContainer);")
        script.AppendLine("   container.set_activeTabIndex(num);")
        script.AppendLine("}")
        script.AppendLine("//]]>")
        script.AppendLine("</script>")

        Page.ClientScript.RegisterClientScriptBlock(GetType(myPageOrControl), " ChangeTab", script.ToString)
    End Sub

The end result is client scripting that will set the tab active when the link is clicked.

MADCookie