ASP CascadingDropDown 控件导致 IE 脚本超时

发布于 2024-12-14 10:27:19 字数 2948 浏览 2 评论 0原文

在加载页面之前,我使用一个子例程将 DropDownList 控件链接在一起:

Private Sub CreateCascadingDropDown(ByVal category As String, ByRef parentDDL As DropDownList, ByRef targetDDL As DropDownList)
            Dim CDDL As New CascadingDropDown
            With CDDL
                .Category = category
                If Not parentDDL Is Nothing Then
                    parentDDL.Items.Clear()
                    .ParentControlID = parentDDL.ID
                End If
                targetDDL.Items.Clear()
                .TargetControlID = targetDDL.ID
                .PromptText = SharedWeb.GC_SELECTONE
                .PromptValue = "-1"
                .LoadingText = "Please wait..."
                .ServicePath = "/ajax/InvestmentProcess.asmx"
                .ServiceMethod = "GetTaxo"
            End With
            'Page.ClientScript.RegisterForEventValidation(CDDL.UniqueID)
            targetDDL.Parent.Controls.Add(CDDL)
        End Sub

当调用 Web 服务方法时,它会执行以下代码。根据类别,它从适配器获取适当的数据。

<WebMethod()> _
    Public Function GetTaxo(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
        Dim log As ILog = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
        log.Debug("GetSegmentTaxonomy(" + category + ") -> {" + knownCategoryValues + "}")
        Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
        Dim adapter As New SegmentTaxonomyTableAdapters.SEGMENT_ARCHITECTURE_TableAdapter
        Dim rows As DataRowCollection

        Select Case category
            Case InvestmentEdit.ST_SEG_ARCH
                rows = New SegmentTaxonomyTableAdapters.SEGMENT_ARCHITECTURE_TableAdapter().GetData().Rows
            Case InvestmentEdit.ST_LOB
                If kv.ContainsKey(InvestmentEdit.ST_SEG_ARCH) Then
                    log.Debug("found seg architecture - > " + kv(InvestmentEdit.ST_SEG_ARCH))
                    rows = New SegmentTaxonomyTableAdapters.LINE_OF_BUSINESSTableAdapter().GetData(kv(InvestmentEdit.ST_SEG_ARCH)).Rows
                End If
        End Select

        If Not rows Is Nothing Then
            Dim results As New List(Of CascadingDropDownNameValue)
            For Each row As DataRow In rows
                log.Debug("ROW >>>> " + row("lov_label").ToString() + " : " + row("lov_cd").ToString())
                results.Add(New CascadingDropDownNameValue(row("lov_label"), row("lov_cd")))
            Next
            Return results.ToArray
        End If
        Return Nothing
    End Function

我需要将大约 5 个下拉列表链接在一起。如果顶级下拉控件 (myDDL) 是唯一像这样链接的控件,则它可以正常加载:

CreateCascadingDropDown("MyCat",Nothing,myDDL)

但是当我链接第二个下拉控件时,Internet Explorer 会出现脚本超时。如果我继续允许脚本运行,它只会继续给我提示。如果选择停止运行脚本,我会收到方法错误 12031 或错误 500(是的,我的 Web 服务文件中有 ScriptService() 声明)。关于造成这种情况的原因有什么想法吗?

Before a page is loaded, I use a subroutine to link DropDownList controls together:

Private Sub CreateCascadingDropDown(ByVal category As String, ByRef parentDDL As DropDownList, ByRef targetDDL As DropDownList)
            Dim CDDL As New CascadingDropDown
            With CDDL
                .Category = category
                If Not parentDDL Is Nothing Then
                    parentDDL.Items.Clear()
                    .ParentControlID = parentDDL.ID
                End If
                targetDDL.Items.Clear()
                .TargetControlID = targetDDL.ID
                .PromptText = SharedWeb.GC_SELECTONE
                .PromptValue = "-1"
                .LoadingText = "Please wait..."
                .ServicePath = "/ajax/InvestmentProcess.asmx"
                .ServiceMethod = "GetTaxo"
            End With
            'Page.ClientScript.RegisterForEventValidation(CDDL.UniqueID)
            targetDDL.Parent.Controls.Add(CDDL)
        End Sub

When the web service method is called, it executes the following code. Based on the category, it gets the appropriate data from the adapter.

<WebMethod()> _
    Public Function GetTaxo(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
        Dim log As ILog = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)
        log.Debug("GetSegmentTaxonomy(" + category + ") -> {" + knownCategoryValues + "}")
        Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
        Dim adapter As New SegmentTaxonomyTableAdapters.SEGMENT_ARCHITECTURE_TableAdapter
        Dim rows As DataRowCollection

        Select Case category
            Case InvestmentEdit.ST_SEG_ARCH
                rows = New SegmentTaxonomyTableAdapters.SEGMENT_ARCHITECTURE_TableAdapter().GetData().Rows
            Case InvestmentEdit.ST_LOB
                If kv.ContainsKey(InvestmentEdit.ST_SEG_ARCH) Then
                    log.Debug("found seg architecture - > " + kv(InvestmentEdit.ST_SEG_ARCH))
                    rows = New SegmentTaxonomyTableAdapters.LINE_OF_BUSINESSTableAdapter().GetData(kv(InvestmentEdit.ST_SEG_ARCH)).Rows
                End If
        End Select

        If Not rows Is Nothing Then
            Dim results As New List(Of CascadingDropDownNameValue)
            For Each row As DataRow In rows
                log.Debug("ROW >>>> " + row("lov_label").ToString() + " : " + row("lov_cd").ToString())
                results.Add(New CascadingDropDownNameValue(row("lov_label"), row("lov_cd")))
            Next
            Return results.ToArray
        End If
        Return Nothing
    End Function

There are about 5 drop downs I need to link together. The top-level drop down control (myDDL) loads fine if it is the only one linked like so:

CreateCascadingDropDown("MyCat",Nothing,myDDL)

But when I link a second drop down control, Internet Explorer gives a script timeout. If I keep allowing the script to run, it just keeps giving me the prompt. If elect to discontinue running the script, I get a Method Error 12031 or Error 500 (and yes, I have the ScriptService() declaration in my web service file). Any ideas on what's causing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨夜星沙 2024-12-21 10:27:19

事实证明,我只需要从 Ajax Control Toolkit 添加以下控件:

<ajax:ToolkitScriptManager ID="tsm" runat="server" />

我需要使用:而不是 .TargetControlID = targetDDL.ID:

.TargetControlID = targetDDL.UniqueId

It turns out I just needed to add the following control from the Ajax Control Toolkit:

<ajax:ToolkitScriptManager ID="tsm" runat="server" />

Instead of .TargetControlID = targetDDL.ID I needed to use:

.TargetControlID = targetDDL.UniqueId
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文