Ajax Tookit TabPanel Error Invisible Tag

I came across a slightly bizarre bug when using the Tabaanel tool to control ajax. I have 4 tabs per line:

[Tab1] [Tab2] [tab3] [tab4]

Now tab 2 should only appear in certain circumstances, and therefore its visibility is set to false. However, while it is invisible, if I pressed Tab 3, it loaded the tab before switching to tab 1. Likewise, selecting tab4 will load tab4, and then immediately switch to tab3. On the server side, the ActiveTabChanged event is fired twice, once for a correctly selected tab, once for a tab that it also switches.

If I put Tab2 at the end of the tab bar, everything will be fine. If you got a little familiar with the toolkit, I assume that this is a bug related to the active tab index, and javascript sets it one lower than it should, but I'm not sure how to do it.

+6
source share
1 answer

I am not sure that this is the same problem, but it is similar to the one that I had for several months. Check out my problem and solution here:

I had to fix the error in the Ajax-Toolkit from PreRender:

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender 'ensure that the Tabs stay invisible that have Visible=False on markup and dont get visible programmatically' Me.TabThatShouldStayInvisible.Visible = False FixTabPanelVisible(TabContainer1) End Sub Protected Sub FixTabPanelVisible(ByVal tabcontainer As AjaxControlToolkit.TabContainer) For Each tp As AjaxControlToolkit.TabPanel In tabcontainer.Tabs Dim oldVisible As Boolean = CBool(IIf(IsNothing(ViewState(tp.UniqueID + "_Display")), True, ViewState(tp.UniqueID + "_Display"))) If Not tp.Visible Then ViewState(tp.UniqueID + "_Display") = False DisableTab(tabcontainer, tabcontainer.Tabs.IndexOf(tp)) ElseIf tp.Visible AndAlso Not oldVisible Then ViewState(tp.UniqueID + "_Display") = True EnableTab(tabcontainer, tabcontainer.Tabs.IndexOf(tp)) End If tp.Visible = True Next Dim fixScript As New StringBuilder() fixScript.Append("function DisableTab(container, index) {$get(container.get_tabs()[index].get_id() + ""_tab"").style.display = ""none"";}") fixScript.Append("function EnableTab(container, index) {$get(container.get_tabs()[index].get_id() + ""_tab"").style.display = """";}") ScriptManager.RegisterStartupScript(Me, Me.GetType(), "FixScriptReg", fixScript.ToString(), True) End Sub Protected Sub EnableTab(ByVal container As AjaxControlToolkit.TabContainer, ByVal index As Integer) Dim sFunction As String = "function () {EnableTab($find('" & container.ClientID & "')," & index & ");}" ScriptManager.RegisterStartupScript(Me, Me.GetType(), "EnableTabFun" & index, "Sys.Application.add_load(" & sFunction & ");", True) End Sub Protected Sub DisableTab(ByVal container As AjaxControlToolkit.TabContainer, ByVal index As Integer) Dim sFunction As String = "function () {DisableTab($find('" & container.ClientID & "')," & index & ");}" ScriptManager.RegisterStartupScript(Me, Me.GetType(), "DisableTabFun" & index, "Sys.Application.add_load(" & sFunction & ");", True) End Sub 
+3
source

Source: https://habr.com/ru/post/888305/


All Articles