Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7180117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:16:51+00:00 2026-05-28T17:16:51+00:00

How to open new browser window on button click event in C# ASP.NET? Please

  • 0

How to open new browser window on button click event in C# ASP.NET?

Please share any example.

I am doing following code. Please let me know where I am going wrong.

btn_Click()
{
    if(condition==true)
    {
        this.Page.ClientScript.RegisterStartupScript(
            this.GetType(),
            "page_index_script2", 
            "openNewWindow();", 
            true
        );
    }
}

And the JavaScript function is

function openNewWindow()
{
    alert('HI');
    window.open('http://www.stackoverflow.com');  
}

When I run the code from javascript function Alert works but new window is not getting opened.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:16:52+00:00Added an answer on May 28, 2026 at 5:16 pm

    You can use some code like this, you can adjust a height and width as per your need

        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);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have listbox and on click event I open new panel where i change
I want to open a new browser window with a specific url (say http://google.com
I use a combination of html/php and javascript to open a new browser window
I have an asp.net search screen which displays the results in a new browser
I'm working on this project and I have to open a new browser tab.
I have window form in my WPF Application when I open new window from
I need to open a new window from code-behind on post-back if a specific
I am trying open a new window using url.Action. And the new Window url
I cannot open a new window in QT. I new in QT so I
I need to open window pop-up from Silverlight Out-of-Browser application. I've added parameter <param

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.