all groups > asp.net webcontrols > january 2007 >
You're in the

asp.net webcontrols

group:

UpdatePanel, Postback


UpdatePanel, Postback marss
1/25/2007 3:05:43 AM
asp.net webcontrols:
Hello,
I have a question concerning UpdatePanel.
For example, I have two linkbuttons at the UpdatePanel. I want the
Button1 linkbutton to update controls within panel (the TextBox1
control in this case), and the Button2 linkbutton perform redirect to
another page. When I click on Button2 it returns a new page content as
the result of the asynchronous request.

<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:LinkButton ID="Button1" Runat="server">Change
textbox</asp:LinkButton>
<asp:LinkButton ID="Button2" Runat="server">Redirect to another
page</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>

Is there any way to do ordinary postback by means of a control placed
on UpdatePanel? For some reason I can't remove Button2 out of the
UpdatePanel.

Thanks.
RE: UpdatePanel, Postback Milosz Skalecki [MCAD]
1/25/2007 4:00:01 AM
Hi Mate,

Yes, two ways:
1. Specify which control can cause asynchronous postback
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"/>
<asp:LinkButton ID="Button1" Runat="server" Text="Change textbox"/>
<asp:LinkButton ID="Button2" Runat="server" Text="Redirect to another
page"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1"/>
</Triggers>
</asp:UpdatePanel>

2. Redirect to another page using javascript (use it if you don’t need to
post back the page and then redirect)
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"/>
<asp:LinkButton ID="Button1" Runat="server" Text="Change textbox"/>
<asp:LinkButton ID="Button2" Runat="server" Text="Redirect to another
page" OnClientClick="window.location.href = 'anotherpage.aspx'; return
false;"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1"/>
</Triggers>
</asp:UpdatePanel>

--
Milosz


[quoted text, click to view]
Re: UpdatePanel, Postback marss
1/25/2007 4:41:26 AM

[quoted text, click to view]
Thanks a lot.
AddThis Social Bookmark Button