Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force full post-back from a button within an UpdatePanel?

How do I force full post-back from a button within an UpdatePanel?

like image 722
André Pena Avatar asked Mar 30 '10 13:03

André Pena


People also ask

How do I stop UpdatePanel from causing the whole page postback?

Another possible reason is that if the page has ClientIDMode="static" , then controls that you expect to refresh just the UpdatePanel will refresh the whole page. To fix the problem, you just need to set ClientIDMode="AutoID" on the control(s) which should trigger the UpdatePanel post back.

What happens when a button placed in the UpdatePanel control is clicked?

The UpdatePanel control contains a Button control that refreshes the content inside the panel when you click it. By default, the ChildrenAsTriggers property is true. Therefore, the Button control acts as an asynchronous postback control.

What is postback trigger in UpdatePanel?

Description. <asp:AsyncPostBackTrigger> Specifies a control and event that will cause a partial page update for the UpdatePanel that contains this trigger reference. <asp:PostBackTrigger> Specifies a control and event that will cause a full page update (a full page refresh).

What is an UpdatePanel control in Ajax?

Introduction. UpdatePanel controls are a central part of AJAX functionality in ASP.NET. They are used with the ScriptManager control to enable partial-page rendering. Partial-page rendering reduces the need for synchronous postbacks and complete page updates when only part of the page has to be updated.


2 Answers

You can use the Triggers property of the UpdatePanel to register actions that trigger a full postback.

Add a PostBackTrigger object to that property, containig the ControlID of the control which needs to trigger a full postback.

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">     <ContentTemplate>         ...     </ContentTemplate>     <Triggers>         <asp:PostBackTrigger ControlID="myFullPostBackControlID" />     </Triggers> </asp:UpdatePanel> 
like image 99
Thibault Falise Avatar answered Oct 24 '22 11:10

Thibault Falise


Just adding this because nobody else has. It is possible to do this in code-behind in one line of code without any of the above methods. Just put this in page_load:

Visual Basic

ScriptManager.GetCurrent(Me).RegisterPostBackControl(myButtonID) 

C#

ScriptManager.GetCurrent(this).RegisterPostBackControl(myButtonID); 
like image 41
EvilDr Avatar answered Oct 24 '22 11:10

EvilDr