Tuesday, 4 November 2014

open new browser window on button click event in asp.net

Suppose you want to open a window from code behind on button click or other event in asp.net, you just following code as per your requirement.

 protected void button_Click(object sender, EventArgs e)
    {
        // open a pop up window at the center of the page.
        ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft                           = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);                                window.open( 'your_page.aspx', null, 'height=700,width=760,                               status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,                               top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
    }

No comments:

Post a Comment