Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net RegisterStartupScript不';在Framework2.0上的IIS 6.0下,从UpdatePanel启动时无法工作_Vb.net_Iis 6_Updatepanel_C# 2.0_Registerstartupscript - Fatal编程技术网

Vb.net RegisterStartupScript不';在Framework2.0上的IIS 6.0下,从UpdatePanel启动时无法工作

Vb.net RegisterStartupScript不';在Framework2.0上的IIS 6.0下,从UpdatePanel启动时无法工作,vb.net,iis-6,updatepanel,c#-2.0,registerstartupscript,Vb.net,Iis 6,Updatepanel,C# 2.0,Registerstartupscript,我到处找了,但没有找到解决办法。希望您能帮助: 我正在维护一个用VB.NET编写并在Framework2.0下运行的网站 在我的一个页面中,UpdatePanel中有一个下拉控件: <asp:UpdatePanel ID="pnlDropDown" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true"> <ContentTemplate> <asp:

我到处找了,但没有找到解决办法。希望您能帮助:

我正在维护一个用VB.NET编写并在Framework2.0下运行的网站

在我的一个页面中,UpdatePanel中有一个下拉控件:

<asp:UpdatePanel ID="pnlDropDown" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <asp:DropDownList ID="ddlTest" runat="server" Width="400"
                OnSelectedIndexChanged="ddlTest_SelectedIndexChanged" AutoPostBack="true">
                <asp:ListItem Text="--- Please Select ---" Selected="True"></asp:ListItem>
                <asp:ListItem Text="111"></asp:ListItem>
                <asp:ListItem Text="222"></asp:ListItem>
                <asp:ListItem Text="333"></asp:ListItem>
            </asp:DropDownList>
        </ContentTemplate>
    </asp:UpdatePanel>
现在我的问题是: 当我从下拉列表中选择一个值时,“RegisterStartupScript”方法将不起作用,但它仅在项目在IIS 6和Framework 2.0下运行时才会发生。 -如果我把它改为在IIS7下运行,它会工作得很好。 -如果我把它改为在Framework4.0下运行,它就可以完美地工作。 -如果我删除UpdatePanel部分,它就会工作

但如果我不改变任何事情,它也不会做任何事情

在我将整个代码更改为使用jquery和ajax之前,有什么解决方案吗?:)

谢谢


Orit.

以下是我为避免使用RegisterStartupScript而找到的解决方法。它很简单,工作非常完美:

  • 我在UpdatePanel中添加了一个名为“hdnTest”的隐藏字段:

  • 在客户端,我添加了一个pageLoad()函数,该函数获取隐藏字段的值并根据该值进行操作:

     function pageLoad(){            
        if ($("#hdnTest").val() == "true") 
            alert('true');             
        else
            alert('false');               
     }
    
  • 很好用

    奥里特

    <asp:UpdatePanel ID="pnlDropDown" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:HiddenField ID="hdnTest" runat="server" />
        <asp:DropDownList ID="ddlTest" runat="server" Width="400"
            OnSelectedIndexChanged="ddlTest_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Text="--- Please Select ---" Selected="True"></asp:ListItem>
            <asp:ListItem Text="111"></asp:ListItem>
            <asp:ListItem Text="222"></asp:ListItem>
            <asp:ListItem Text="333"></asp:ListItem>
        </asp:DropDownList>
    </ContentTemplate>
    
    Protected Sub ddlTest_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        If x Then
            hdnTest.Value = "true"
        Else
            hdnTest.Value = "false"
        End If
        pnlDropDown.Update()
    End Sub 
    
     function pageLoad(){            
        if ($("#hdnTest").val() == "true") 
            alert('true');             
        else
            alert('false');               
     }