user1102001
user1102001

Reputation: 707

Script manager is unable to open aspx page in new window in c#

below is my Code

protected void btnprnt_Click(object sender, EventArgs e)
{
    //Response.Redirect("Print.aspx");

    string url = "Print.aspx?ID=1&cat=test";
    string script = "window.open('" + url + "','')";
    if (!ClientScript.IsClientScriptBlockRegistered("NewWindow"))
    {
        //clientScript.RegisterClientScriptBlock(this.GetType(), "NewWindow", script, true);
        ScriptManager.RegisterClientScriptBlock(this,this.GetType(), "NewWindow", script, true);
    }

   }

Problem is my Print.aspx is not open in new window.
the page is open but not in new window. even page is redirecting.

Upvotes: 1

Views: 2363

Answers (2)

Dimi Takis
Dimi Takis

Reputation: 4949

You need the following

string script = "window.open('" + url + "','_blank')";

Upvotes: 1

devdigital
devdigital

Reputation: 34349

Your parameters for the window.open function are incorrect. The second parameter is overriding the target attribute, you should remove this.

string script = "window.open('" + url + "')";

Upvotes: 0

Related Questions