i have an update panel with a menu in it.
i wanna to redirect to another page when the user click on the print button in grid view in user control (in my update panel)
i used these codes,but they didn't work for me:
1 : Response.Redirect("PrintTicket.aspx");
2 : Response.Write("<script>window.open('PrintTicket.aspx','_parent');</script>");
3 : Page.Response.Redirect("PrintTicket.aspx", true);
4 : Page.ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", "<script language='javascript' type='text/javascript'>window.location.replace('http://vinaticket.ir /PrintTicket.aspx');</script> ", false);
5 : ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect","window.location='" + Request.ApplicationPath + "PrintTicket.aspx';", true);
6 : Page.ClientScript.RegisterStartupScript(typeof(Page), "ClientScript", "<script language='javascript' type='text/javascript'> postRefId('" + Session["TicketID"].ToString() + "');</script> ", false);
7 : ScriptManager.RegisterStartupScript(this, this.GetType(), "redir", "document.location = 'PrintTicket.aspx'", true);
this is my code :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
----menu .... with exit button
<asp:PlaceHolder ID="PlaceHolder1" runat="server" ViewStateMode="Enabled">
</asp:PlaceHolder>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="exit" />
</Triggers>
</asp:UpdatePanel>
//code behind to loade user control
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}
private void LoadUserControl()
{
try
{
string controlPath = LastLoadedControl;
if (!string.IsNullOrEmpty(controlPath))
{
PlaceHolder1.Controls.Clear();
UserControl uc = (UserControl)LoadControl(controlPath);
PlaceHolder1.Controls.Add(uc);
}
}
catch (Exception ex) { }
}
my menu button :
protected void your_ticket_Click(object sender, EventArgs e)
{
try
{
Session["pg"] = "Z_ViewTicket.ascx";
setPath();
}
catch (Exception ex) { }
}
and set path method():
protected void setPath()
{
try
{
string controlPath = string.Empty;
controlPath = BASE_PATH + Session["pg"].ToString();
LastLoadedControl = controlPath;
LoadUserControl();
}
catch (Exception ex) { }
}
Note: i test a sample code and i find the reason, in my sample code i drag user control to my update panel and the button worked, but when i call user control by these codes the button doesn't work(in case one the user control register to main page but in case two there isn't any register code in main page)
and for this problem how can i redirect to other page?