Workaround for Response.Redirect

This is a workaround to do a redirect while using ASP.NET AJAX Framework. The traditional Response.Redirect method can not be used since it is not compatible with the .NET AJAX framework.

StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">\n");
sb.Append("function Redirect()\n");
sb.Append("{\n");
sb.Append("     window.parent.location.href = \"" + ResolveUrl(myURL) + "\";\n");
sb.Append("}\n");
sb.Append("</script>\n");

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Redirect", sb.ToString());
myBtn.Attributes.Add("onclick", "return Redirect();");
If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!