Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 466
  • Last Modified:

Redirect after AJAX call

Hi,

I have an ASP.NET web page which displays details of a job within an Infragistics WebTab which is AJAX enabled.

Within this tab is a delete button which when clicked will use an AJAX callback to call a delete function on the server.  This deletes the job from the back-end database.  What i want to do on return from the callback is to re-direct to another page.

How can I do this?  I am coding using C#.  I guess a relasted question would be that if I have a button which is within an AJAX container can I make the button perform a normal postback rather than an AJAX callback?
0
ChrisMDrew
Asked:
ChrisMDrew
1 Solution
 
Tuyau2poilCommented:

you can add "triggers" tag to your UpdatePanel and specify wich control must do a postback.
in page_load code behind, redirect page if certain condition is met (for example you can test hidden control value that you set before postback).

example :

aspx page :

 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
   
      .......(page asp and html code, controls etc...)
     <asp:Button ID="MyButton" runat="server" CssClass="but" Height="32px" Text="Hello"  Width="74px" />
     <asp:Label ID="Test" runat="server" Visible="False"></asp:Label>
                                     

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

</asp:UpdatePanel>


code behind :


 Protected Sub myButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyButton.Click

... do some stuff

test.text="postback send by mybutton"

end sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

If IsPostBack Then
  if test.text="postback send by mybutton" then
  reponse.redirect("anotherPage.aspx")
  end if
end if

Exit Sub







   
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now