gpt4 book ai didi

asp.net - Ajaxtoolkit TabPanel Invisible Tag Bug

转载 作者:行者123 更新时间:2023-12-04 15:36:58 29 4
gpt4 key购买 nike

我在使用 ajax 控件工具包 TabPanel 时遇到了一个稍微奇怪的错误。我有 4 个标签,如下所示:

[Tab1][Tab2][Tab3][Tab4]

现在选项卡 2 应该只出现在某些情况下,因此将其可见性设置为 false。然而,虽然它是不可见的,但如果我单击 Tab 3,它会在切换到 Tab 1 之前加载该选项卡。同样选择 tab4 将加载 tab4,然后立即切换到 tab3。在服务器端,ActiveTabChanged 事件被击中两次,一次是正确选择的选项卡,一次是它正在切换的选项卡。

如果我将 Tab2 移动到选项卡行的末尾,则一切正常。稍微阅读了工具包后,我认为这是与事件选项卡索引有关的错误,并且 javascript 将其设置为低于应有的值,但我不确定如何修复它。

最佳答案

我不确定这是否是同一个问题,但听起来与我几个月以来遇到的问题相似。在这里查看我的问题和解决方案:

  • forums.asp.net: hiding TabContainer TabPanels

  • 我不得不从 PreRender 修复 Ajax-Toolkit 中的一个错误:
    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

    关于asp.net - Ajaxtoolkit TabPanel Invisible Tag Bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6029648/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com