1

I want to set target =_blank to the following code, so that the Test.aspx page open in new window.

 Response.Redirect("Test.aspx?D1=" + TextBox1.Text + "&D2=" + TextBox2.Text);

How can I do that?

Mark
  • 8,046
  • 15
  • 48
  • 78
Gaurav
  • 557
  • 4
  • 11
  • 28

1 Answers1

5

try to add this to your object:

OnClientClick="aspnetForm.target ='_blank';"

or put it in ASP.NET like here:

<asp:LinkButton ID="myButton" runat="server" Text="Click Me!" 
                OnClick="myButton_Click" 
                OnClientClick="aspnetForm.target ='_blank';"/>

like in here

The other part you need to add is to fix the form's target otherwise every link will open in a new window. To do so add the following in the header of your POPUP window.

<script type="text/javascript">
    function fixform() {
        if (opener.document.getElementById("aspnetForm").target != "_blank") return;
        opener.document.getElementById("aspnetForm").target = "";
        opener.document.getElementById("aspnetForm").action = opener.location.href;
    }
</script>

and then add:

<body onload="fixform()">
Community
  • 1
  • 1
Mark
  • 8,046
  • 15
  • 48
  • 78
  • where to put? its not working properly if I set it on Page_Load – Gaurav May 28 '13 at 06:10
  • yes I red that one. but the problem is when I put OnClientClick="aspnetForm.target ='_blank';", only one button then it works for every button on the master page. why? – Gaurav May 28 '13 at 10:45