2012年3月26日月曜日

Response.Redirect not working while inside an Update Panel

I have a link button inside an update panel. When the user clicks this button, it calls a function that performs a database update and then redirects them to another page. However, Response.Redirect isn't working with AJAX. Any suggestions how I can do this? Thanks!Can you post your code here?

Hi,

Reponse.Redirect works with UpdatePanel. Please refer to this sample:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("http://www.microsoft.com"); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

0 件のコメント:

コメントを投稿