views:

47

answers:

2

Hello, I have some controls within an UpdatePanel. Included are some buttons. How can I make these buttons so that they do a full postback rather than a partial AJAX postback?

+4  A: 

Use a PostbackTrigger rather than an AsyncPostbackTrigger

rchern
+2  A: 

Here's an example demonstrating how to use the PostbackTrigger instead of the AsyncPostbackTrigger:

ASPX Page:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Label ID="MyLabel" runat="server" />
        <br/>
        <asp:button ID="AjaxPostbackButton" Text="AJAX Postback" OnClick="AjaxPostbackButton_Click" runat="server" />
        <asp:button ID="FullPostbackButton" Text="Full Postback" OnClick="FullPostbackButton_Click" runat="server" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="AjaxPostbackButton" />
        <asp:PostBackTrigger ControlID="FullPostbackButton" />
    </Triggers>
</asp:UpdatePanel>

Code Behind:

private void AjaxPostbackButton_Click(object sender, EventArgs e)
{
    MyLabel.Text = "Ajax Postback: " + DateTime.Now;
}

private void FullPostbackButton_Click(object sender, EventArgs e)
{
    MyLabel.Text = "Full Postback: " + DateTime.Now;
}

Clicking on the "AJAX Postback" button will will update the panel using AJAX whereas the "Full Postback" button will reload the entire page.

Mun