Skip to main content

Popup window on button click in asp net

On Button Click How Open A page in new window in asp.net - c# code

Task: Open a new window using c# code in asp.net website/web application.
Description: The problem is this we can use Response.Redirect() method for redirect/open  new webpage in same window, But how we can open a new page in new window.

Previously I was Explained about the How to remove rows from GridView using jQuery in asp.net, Nested GridView in ASP.NET Using c# with show/hide ,  How to Add a Locked Header Row to an ASP.NET GridView Control ,  How to remove rows from GridView using jQuery in asp.net

So that I use javascript code(alert box) for popup new window in c# code behind file as describe below. I write below code on Button Click Event.

// Dynamic Alert box javascript using c# code in asp.net

 protected void btngeneraterecipt_Click(object sender, EventArgs e)
    {
        try
        {
            string queryString = "billformat.aspx";
            string jquery = "window.open('" + queryString + "');";
            ScriptManager.RegisterStartupScript(this,this.GetType(), "pop", jquery, true);
        }
        catch (Exception ee)
        {
            Label1.Text = ee.Message;
        }
    }

Comments