簡體   English   中英

ASP 更新面板不起作用

[英]The ASP UpdatePanel doesn't work

我嘗試使用 UpdatePanel 更新我的 aspx 頁面的一部分,但它不起作用

這是aspx頁面代碼的一部分:

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>                                
           <asp:CheckBox ID="cb1" name="cb1" runat="server" OnCheckedChanged="cb_test_CheckedChanged" AutoPostBack="true" /><label for="cb1"><%=DateTime.Now %></label>
    </ContentTemplate>
</asp:UpdatePanel>

這是后面的部分代碼:

protected void cb_test_CheckedChanged(object sender, EventArgs e)
    {
        UpdatePanel1.Update();
    }

當我嘗試單擊復選框時,不會想到 TextBox。

注意:在瀏覽器控制台中,我有:

Error: Sys. WebForms. PageRequestManagerParserErrorException: impossible to analyze the message received from the waiter(server). This error can have several possible causes: answer modified by calls(appeals) to Response. Write (), leak out of answer, HttpModules or activation of track of the waiter(server). Details: error of analysis near '

如果您將復選框放在更新面板之外,它將起作用,同時刪除 UpdatePanel1.Update(); 從代碼隱藏

<asp:CheckBox ID="cb1" name="cb1" runat="server" OnCheckedChanged="cb_test_CheckedChanged" AutoPostBack="true" /><label for="cb1">Example</label>
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
    <ContentTemplate>            
        <asp:TextBox runat="server" ID="bidon" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger  ControlID="cb1" />
    </Triggers>
</asp:UpdatePanel>


        protected void cb_test_CheckedChanged(object sender, EventArgs e)
    {
        bidon.Text = DateTime.Now.ToString();
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM