Does ajax updatepanel always fire page_load event?

I am new to ajax and am using visual studio 2005 and framework 2.0. A simple example Ajax always accepts a page load event for a button click. No deployment, and all in debug mode only, will lead me to the Page_Load event. I don’t know what the problem is? I checked the values ​​of UpdatePanel1.IsInPartialRendering and ScriptManager1.IsInAsyncPostBack , which are false . Here is my code

  <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 and stackoverflow are not helping me yet. Therefore, any heart hearts help me ...

+4
source share
2 answers

Internal Update Control Panel Reason for asynchronous postback . What is Asynchronous Postback? From Refrence to 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 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 .

Now, if this raises all the events on the server, than using Partial Rendering ...

Partial page processing eliminates the need for the entire page to be refreshed as a result of postback. Instead, only selected regions of the modified page are updated. As a result, users do not browse the entire page with each postback, which makes the user experience smoother interaction with the web page.

+7
source

I'm a little rusty on my Web.forms, but as far as I remember, this is by design. Page_Load starts when the AJAX update panel sends a request to the server.

0
source

Source: https://habr.com/ru/post/1490412/


All Articles