UpdatePanel, Postback

M

marss

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.
 
G

Guest

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>
 
M

marss

Milosz said:
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>
Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top