How do I force full post-back from a button within an UpdatePanel?
5 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>

- 5,795
- 2
- 29
- 32
-
I have an Infragistics UltraWebGrid with a column that consists of buttons. I had a problem where clicking on the buttons would fire their event handlers, which in turn refreshes the grid, but the grid would not actually refresh visibly until the second click. Putting the buttons in an UpdatePanel and adding these triggers solved the problem. – tsilb Feb 21 '13 at 21:05
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);

- 8,943
- 14
- 73
- 133
-
3Very nice, after hours of searching, finally a solution that works. The issue was all my controls (update panel and button) were being created in code behind so a postbacktrigger could not be set. Thanks! – OverMars Nov 29 '12 at 17:29
-
2You should be able to. When the control is created you can use AddHandler to create the trigger to your responding Subroutine – EvilDr Nov 30 '12 at 08:59
-
Absolutely right, its so simple and right there I'm almost embarrassed it never occurred to me. Very nice though.. – OverMars Nov 30 '12 at 19:14
-
-
2Me is visual basic for the page. I think in C# you can use `this` or `page` – EvilDr Mar 06 '16 at 07:38
-
This only works with ONE updatepanel and ONE trigger button. What if the updatepanel is inside a Gridview row, where each updatepanel and trigger button has a unique ClientID? – Fandango68 Jul 05 '16 at 06:01
-
In the GridView.RowCreated method, apply exactly the same logic to achieve the same – EvilDr Jul 05 '16 at 10:15
-
Thanks, you helped me in another problem with AjaxToolKit.HtmlEditor within popup. – jmsandy Jun 25 '19 at 13:58
From here:
Use the PostBackTrigger control to enable controls inside an UpdatePanel to cause a postback instead of performing an asynchronous postback.
<Triggers>
<asp:PostBackTrigger ControlID="controlID" />
</Triggers>

- 21,087
- 11
- 87
- 112
-
Hmm yeah but won't work if inside that UpdatePanel you have a GridView with Page numbers for example. Change to a new page and the triggers no longer work. – Fandango68 Jul 05 '16 at 06:02
I had the same problem using an ImageButton inside a WebDataGrid.
I put the Line from EvilDr inside the preRender for the webdatagrid instead. Worked great!
for (int i = 0; i < wdgMyData.Rows.Count; i++)
{
ScriptManager.GetCurrent(this).RegisterPostBackControl((ImageButton)wdgMyData.Rows[i].Items[3].FindControl("btnDownloadExcel"));
}

- 1
Its an old question there is bit tricky approach as well, when everything is in update panels and you want to do full post back so that your Document.Ready code works on click.
1. Create a dummy button outside the update panel and click it from code behind like this
ScriptManager.RegisterStartupScript(Page, this.GetType(), "ResetDoc", "ResetDocumentReady();", true);
2. Define the function on front end like this
function ResetDocumentReady() {
$("[id$=DummyButton]").click();
}
NOTE: But the best way is using trigger, the answer posted by @Thibault Falise :)

- 799
- 1
- 8
- 15