0

I'm trying to open new html page in new tab using of c# inside of asp.net. I have

protected void btnShowMatrix_Click(object sender, EventArgs e)
    {
        string url = @"http://localhost/IMApp/static/knit.html";
        Response.Redirect(url);
    }

This works fine but I need to open that html page in new tab. Is there any simple way, how to do that. Many thank in advance.

SmithiM
  • 231
  • 3
  • 10
  • 1
    Use `HyperLink`. http://stackoverflow.com/questions/1191747/how-to-open-asphyperlink-navigationurl-in-a-new-tab – Bharadwaj Mar 29 '16 at 07:43
  • Call Matrix Works fine for me. Is there any way how can I call hplShowMatrix as a part of C# procedure, let's say inside of protected void btnShowMatrix_Click(object sender, EventArgs e){} ? – SmithiM Mar 29 '16 at 07:56

1 Answers1

0

You can try this:

protected void btnShowMatrix_Click(object sender, EventArgs e)
{
   Page.ClientScript.RegisterStartupScript(
   this.GetType(),"OpenWindow","window.open('http://localhost/IMApp/static/knit.html','_newtab');",true);
}
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • This gives me the following error message: Failed to load resource: the server responded with a status of 404 (Not Found) – SmithiM Mar 29 '16 at 07:40
  • @SmithiM:- Do check that the url which you are using is correct! – Rahul Tripathi Mar 29 '16 at 07:41
  • Yes, it's correct. – SmithiM Mar 29 '16 at 07:43
  • @SmithiM:- Are you able to open the url `http://localhost/IMApp/static/knit.html` directly from your browser? – Rahul Tripathi Mar 29 '16 at 07:48
  • Yes, I can open that url from my browser. – SmithiM Mar 29 '16 at 07:48
  • @SmithiM:- This is strange as I tried the same code in my system and its working.(*I simply changed the url*) – Rahul Tripathi Mar 29 '16 at 08:03
  • Hmmm, that's really weird... Only if I create new Web Form, then into protected void Page_Load(object sender, EventArgs e) insert string url = @"localhost/IMApp/static/knit.html";; Response.Redirect(url); and call this new web form from mainPage.aspx with Page.ClientScript.RegisterStartupScript( this.GetType(), "OpenWindow", "window.open('http://localhost/IMApp/ShowMatrix.aspx','_newtab');", true); – SmithiM Mar 29 '16 at 08:39