1

The question is simple but I can't find a simple answer to it! .. btw I'll need to pass a QueryString to the page to be open.

Any ideas ?

Mazen Elkashef
  • 3,430
  • 6
  • 44
  • 72
  • 1
    this probably answers your question: http://stackoverflow.com/questions/309979/asp-net-webforms-postback-then-open-popup – Volkmar Rigo Sep 11 '11 at 08:07

3 Answers3

1

You can actually link a javascript code into .NET with C#, below is an example, you could replace with your info, and push the parameters.

   Response.Write("<script type='text/javascript'>window.open('Page.aspx?ID=" + YourTextField.Text.ToString() + "','_blank');</script>");

You can append on the end of it ?Field=your value passing&nextField=another value.

apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69
1

Is the answer to do this in javascript. As you make the underlying page in asp.net, provide it with the javascript to catch the buttons onclick event and call window.open(URL)

akc42
  • 4,893
  • 5
  • 41
  • 60
1

It depends on what you're trying to do but the simplest is to use the OnClientClick property of the Button. Take a look at http://msdn.microsoft.com/en-us/library/7ytf5t7k.aspx, in particular the details bout this property a little bit down.

Basically you'd do something like

<asp:Button ID="Button1" Runat="server" 
        OnClientClick="ShowPopup();" 
        Text="Test Client Click" />

With the JS to do your popup

<script type="text/javascript">
    function ShowPopup() {
        window.open('ThankYou.aspx');
    }
</script>

You can also do both an OnClientClick and an OnClick if you need as well.

<asp:Button ID="Button1" Runat="server" 
      OnClick="Button1_Click" 
        OnClientClick="ShowPopup();" 
        Text="Test Client Click" />

Code behind

    protected void Button1_Click(Object sender, EventArgs e)
    {
        Label1.Text = "Server click handler called.";
    }
Kirk
  • 16,182
  • 20
  • 80
  • 112
  • what do you mean by "this property a little bit down." .. and how can I pass a QueryString to the popup ? – Mazen Elkashef Sep 27 '11 at 20:59
  • I meant a little bit down on the MSDN link. Look in the **To add a client onclick event to a button control** section. Also, where are you getting the query string from details? If you're trying to get a result from the `OnClick` event and pass that to a pop-up, you'll need to take a different approach and either figure out the details manually in the popup or what AmitApollo said and Response.Write it after the postback. – Kirk Sep 28 '11 at 05:19