Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updatepanel in ajax always runs page_load Event?

I'm new to ajax and using visual studio 2005 and framework 2.0. A simple Ajax sample always takes to the page load event for a button click. No deployment and all just running in debug mode takes me to the Page_Load event. Don't know what is the problem? I have checked the values of UpdatePanel1.IsInPartialRendering and ScriptManager1.IsInAsyncPostBack which is 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 doesnt help me so far. So any kind hearts help me...

like image 335
Developer Avatar asked Mar 23 '23 06:03

Developer


1 Answers

Control Inside Update Panel Cause 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.

Now if it cause all event on server than what is the use of Partial Rendering...

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

like image 183
Amit Singh Avatar answered Mar 25 '23 19:03

Amit Singh