I have an asp.net page that contains an Iframe embedded with some data and an ImageButton. On the clickButton click event (server side), I have Response.Redirct:
Response.Redirect("results.aspx");
This always opens results.aspx in the iframe. I want result.aspx to always open in the parent window. I have tried the following so far, but no one has worked:
Response.Redirect("<script language='javascript'>self.parent.location='results.aspx';</script>"); Response.Redirect("javascript:parent.change_parent_url('results.aspx');");
As Rifk answered, I am adding ClientScriptManager. .aspx has this entry:
<asp:ImageButton ID="ImageButton_ok" ImageUrl="~/images/ok.gif" OnClick="btnVerify_Click" OnClientClick="ValidateFields()" runat="server" />
Code behind in Page_Load ():
ClientScriptManager cs = Page.ClientScript; StringBuilder myscript = new StringBuilder(); myscript.Append("<script type=\"text/javascript\"> function ValidateFields() {"); myscript.Append("self.parent.location='default.aspx';} </"); myscript.Append("script>"); cs.RegisterClientScriptBlock(this.GetType(), "ButtonClickScript", myscript.ToString());
btnVerify_Click has the core business logic. How can I stop OnClientClick () to start if my business logic fails? or, how can I run when the server code is successfully executed?
source share