Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET and AJAX: Complete postback with a asp:Button inside an UpdatePanel

This is my aspx code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" 
     UpdateMode="Conditional" RenderMode="Inline" ChildrenAsTriggers="False">
 <ContentTemplate>
    <asp:Button ID="Save" runat="server" Text="Save" 
         onclick="Save_Click" CssClass="boton" />
 </ContentTemplate>
</asp:UpdatePanel>

This button is on an updatepanel beacuse I need to enabled it in a partial postback.

I need that save button make a complete postback. How can I achieve this?

Thank you!

like image 781
VansFannel Avatar asked Feb 28 '23 18:02

VansFannel


1 Answers

You would make a new PostBack trigger inside your updatepanel that is set to the ID of your button.

example:

<Triggers>
    <asp:PostBackTrigger ControlID="Button1" />
</Triggers>

This would go inside your UpdatePanel as another component aside from your content template.

Like this:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" 
     UpdateMode="Conditional" RenderMode="Inline" ChildrenAsTriggers="False">
 <Triggers>
    <asp:PostBackTrigger ControlID="Save" />
 </Triggers>
 <ContentTemplate>
    <asp:Button ID="Save" runat="server" Text="Save" 
         onclick="Save_Click" CssClass="boton" />
 </ContentTemplate>
</asp:UpdatePanel>
like image 174
TheTXI Avatar answered Mar 03 '23 07:03

TheTXI