C# textbox ontextchanged事件正在更新面板中触发,但在客户端抛出错误

C# textbox ontextchanged事件正在更新面板中触发,但在客户端抛出错误,c#,asp.net,ajax,textbox,updatepanel,C#,Asp.net,Ajax,Textbox,Updatepanel,我在第页有两个div。当第一次加载页面时,它显示第一个div,其中有2个单选按钮。若你们选择了第二个按钮,它会回发并隐藏第一个div,并显示第二个div,在更新面板中有文本框和下拉列表。将文本插入文本框并点击tab,它将触发ContextChanged事件。我在下拉列表中添加选项的位置。但它在客户端抛出了错误 error : "Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException

我在第页有两个div。当第一次加载页面时,它显示第一个div,其中有2个单选按钮。若你们选择了第二个按钮,它会回发并隐藏第一个div,并显示第二个div,在更新面板中有文本框和下拉列表。将文本插入文本框并点击tab,它将触发ContextChanged事件。我在下拉列表中添加选项的位置。但它在客户端抛出了错误

error : "Microsoft JScript runtime error:  Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed."
我不知道该怎么办

这是我的aspx页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   /TR/xhtml1/DTD/xhtml1-transitional.dtd">

 <html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
    <title></title>
 </head>
  <body>
    <form id="form1" runat="server">
    <div id="divpanel1" runat="server">
    <asp:Label ID="Label1" runat="server" Text="Label : "></asp:Label>
    <asp:RadioButton ID="RadioButton1" GroupName="lbl" Text="me first" runat="server"/>
    <asp:RadioButton ID="RadioButton2" GroupName="lbl" Text="me second"
        runat="server" AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" />
        </div>
    <div id="divpanel" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
        <asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem Selected="True" Value="0">select</asp:ListItem>
        </asp:DropDownList>
        </ContentTemplate>
        </asp:UpdatePanel>

    </div>
    </form>
   </body>
   </html>

谢谢您的时间。

错误是您需要将
放在更新面板中,因为当控件文本框执行事件
OntextChanged
时,它无法更新控件,并且无法工作

aspx的新代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

    <div id="divpanel1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Label : "></asp:Label>
        <asp:RadioButton ID="RadioButton1" GroupName="lbl" Text="me first" runat="server" />
        <asp:RadioButton ID="RadioButton2" GroupName="lbl" Text="me second" runat="server"
            AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" />
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="divpanel" runat="server">
                <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
                <asp:DropDownList ID="DropDownList1" runat="server">
                    <asp:ListItem Selected="True" Value="0">select</asp:ListItem>
                </asp:DropDownList>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
我希望这能有所帮助

干杯

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">

    <div id="divpanel1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Label : "></asp:Label>
        <asp:RadioButton ID="RadioButton1" GroupName="lbl" Text="me first" runat="server" />
        <asp:RadioButton ID="RadioButton2" GroupName="lbl" Text="me second" runat="server"
            AutoPostBack="true" OnCheckedChanged="RadioButton2_CheckedChanged" />
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="divpanel" runat="server">
                <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
                <asp:DropDownList ID="DropDownList1" runat="server">
                    <asp:ListItem Selected="True" Value="0">select</asp:ListItem>
                </asp:DropDownList>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        this.divpanel.Visible = false; 
    }

}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
    this.DropDownList1.Items.Add(this.TextBox1.Text.ToString());
    DropDownList1.DataBind();
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{
    this.divpanel.Visible = true;
    this.divpanel1.Visible = false;

}