open a new window when a Button is clicked.

csharp , css Gent, Belgium
  • 9 years ago

    Hi,

    I want to add a functionality to the button onclick. When I click on the button, I want to open a new aspx page in a new window and pass a parameter in the querystring.

    Firstly, I tried using response.redirect

    Response.Write("<script>window.open(a.aspx?GTIN=" +gtin.Text+ "');</script>");

    It works, it opens a new window, but something happens to my previous window after the second window loads. The css becomes not used. (at the begin the css loads, but after I click the button, it seems like css is not been used in my previous page).. Any ideas why the css file is not been active when I click on the button.

    Than, I tried,  to add an attribute to the button:

    string command = "window.open(a.aspx?GTIN=" + gtin.Text.Trim() + "');";

    this.bt_image.Attributes.Add("onclick", command);

    and it loads only when I click the second time on the button. First time I click the button, nothing happens.. second time it opens.. Why is that?

    Please let me know what am I missing?

    Thank you

     

     

     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” - Tom Cargill