gpt4 book ai didi

asp.net - ajax 中的 Updatepanel 总是运行 page_load 事件?

转载 作者:行者123 更新时间:2023-12-04 23:55:10 25 4
gpt4 key购买 nike

我是 ajax 的新手并使用 Visual Studio 2005 和框架 2.0。一个简单的 Ajax 示例总是为按钮单击处理页面加载事件。没有部署,所有只是在 Debug模式下运行将我带到 Page_Load事件。不知道是什么问题?我检查了 UpdatePanel1.IsInPartialRendering and ScriptManager1.IsInAsyncPostBack 的值这是 .
这是我的代码,

 <form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" >
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label><br />
<asp:Button ID="Button1" runat="server" Text="PostBack" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToLongTimeString()+UpdatePanel1.IsInPartialRendering+ScriptManager1.IsInAsyncPostBack;
}

到目前为止,Google 和 stackoverflow 对我没有帮助。所以任何善良的心帮助我...

最佳答案

控制内部更新面板原因 asynchronous postback .
什么是异步回发?
从引用资料到 MSDN
An asynchronous postback behaves much like a synchronous postback. All the server page life-cycle events occur, and view state and form data are preserved. However, in the rendering phase, only the contents of the UpdatePanel control are sent to the browser. The rest of the page remains unchanged .

现在,如果它导致服务器上的所有事件而不是使用部分渲染...

Partial-page rendering removes the need for the whole page to be refreshed as the result of a postback. Instead, only individual regions of the page that have changed are updated. As a result, users do not see the whole page reload with every postback, which makes user interaction with the Web page more seamless

关于asp.net - ajax 中的 Updatepanel 总是运行 page_load 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17539480/

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