Go to another page by pressing the button inside an iframe with Response.Redirect

1

I have a page called pagina1.html and inside it an iframe.In the iframe I have a form with a button that I want when I press pass from page1.html to another call pagina2.html that will contain another iframe with another form.

To change the page I put an event on the button and inside the Response.Redirect method but it does not redirect me well to page2.html

protected void Button1_Click(object sender, EventArgs e)
{
   Response.Redirect("../pagina2.html");
}
    
asked by Popularfan 20.07.2018 в 13:16
source

1 answer

1

Update 2 with version for Visual Studio 2008 and .NET 3.5, here you have the documentation for that version, and as you can see is the same way as in the current version but less refactored.

Do you have the namespace added System.Web.UI ?

  // Esto lo tienes?
  using System.Web.UI;

  protected void Button1_Click(object sender, EventArgs e) {
   // Definir que vas a ejecutar en Javascript y el tipo
   String script = "window.parent.location = '../pagina2.html'";
   Type cstype = this.GetType();

   // ClientScriptManager para la pagina
   ClientScriptManager cs = Page.ClientScript;

    // Ejecutar el scriptblock
   cs.RegisterClientScriptBlock(cstype, script, script.ToString(), false);
  }

Update that VS!

I update with a new proposal since it was not a quote error.

It can be done with Javascript with the window.parent ( MDN ) and the property location , to call it from .NET use the ClientScriptManager ( MSDN ).

protected void Button1_Click(object sender, EventArgs e)
{
   ClientScriptManager.RegisterClientScriptBlock(this.GetType(), 
       "RedirectScript", "window.parent.location = '../pagina2.html'", true);
}
    
answered by 20.07.2018 / 13:27
source