how to open a new browser window when clicked on a button control?

Discussion in 'ASP .Net Web Controls' started by buran, Feb 9, 2005.

  1. buran

    buran Guest

    Dear ASP.NET Programmers,

    I am using the following code block to navigate to the invoice page of my
    app. when users click on the button btnInvoice. However, I want to display
    the invoice page in a new browser window. What javascipt code should I use
    instead of Response.Redirect()? Thanks in advance,

    Burak


    Private Sub btnInvoice_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnInvoice.Click
    If txtIRD.Text <> "" And txtInvoiceDate.Text <> "" Then
    Response.Redirect("newinvoice_hospital.aspx?mfuid=" +
    Request("mfuid") + "&spid=" + Request("spid"))
    End If
    If txtIRD.Text = "" Then
    Say("Please enter the invoice receipt date")
    End If
    If txtInvoiceDate.Text = "" Then
    Say("Please enter the invoice date")
    End If
    End Sub
     
    buran, Feb 9, 2005
    #1
    1. Advertising

  2. Burak,

    As you write, you should use javascript instead of Response.Redirect. And
    all your logic that is currently implemented on server sode should move to
    client side. You don't need server roundtrips to check if a text entry field
    is empty.

    There is a number of javascript calls to open a new browser window.
    window.open(...);
    window.showModalDialog(...);
    window.showModelessDialog(...);

    Eliyahu

    "buran" <> wrote in message
    news:%23m00u$...
    > Dear ASP.NET Programmers,
    >
    > I am using the following code block to navigate to the invoice page of my
    > app. when users click on the button btnInvoice. However, I want to display
    > the invoice page in a new browser window. What javascipt code should I use
    > instead of Response.Redirect()? Thanks in advance,
    >
    > Burak
    >
    >
    > Private Sub btnInvoice_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnInvoice.Click
    > If txtIRD.Text <> "" And txtInvoiceDate.Text <> "" Then
    > Response.Redirect("newinvoice_hospital.aspx?mfuid=" +
    > Request("mfuid") + "&spid=" + Request("spid"))
    > End If
    > If txtIRD.Text = "" Then
    > Say("Please enter the invoice receipt date")
    > End If
    > If txtInvoiceDate.Text = "" Then
    > Say("Please enter the invoice date")
    > End If
    > End Sub
    >
    >
     
    Eliyahu Goldin, Feb 9, 2005
    #2
    1. Advertising

  3. buran

    Gold Guest

    just insert the following javascript function in between the head tags

    void opennewwindow()
    {
    var w;
    w=window.open("newpage.aspx");
    }

    and insert the following code in the page_load event

    btnInvoice.Attributes.Add("onclick","opennewwindow();")


    Try :)

    Regards,
    Thangam

    "buran" wrote:

    > Dear ASP.NET Programmers,
    >
    > I am using the following code block to navigate to the invoice page of my
    > app. when users click on the button btnInvoice. However, I want to display
    > the invoice page in a new browser window. What javascipt code should I use
    > instead of Response.Redirect()? Thanks in advance,
    >
    > Burak
    >
    >
    > Private Sub btnInvoice_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnInvoice.Click
    > If txtIRD.Text <> "" And txtInvoiceDate.Text <> "" Then
    > Response.Redirect("newinvoice_hospital.aspx?mfuid=" +
    > Request("mfuid") + "&spid=" + Request("spid"))
    > End If
    > If txtIRD.Text = "" Then
    > Say("Please enter the invoice receipt date")
    > End If
    > If txtInvoiceDate.Text = "" Then
    > Say("Please enter the invoice date")
    > End If
    > End Sub
    >
    >
    >
     
    Gold, Feb 9, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljaw==?=
    Replies:
    2
    Views:
    1,814
    Cathie
    Jan 23, 2004
  2. =?Utf-8?B?Tm92aWNl?=
    Replies:
    2
    Views:
    6,666
    Alan Ferrandiz Langley
    Jun 9, 2004
  3. buran
    Replies:
    2
    Views:
    460
    =?Utf-8?B?R29sZA==?=
    Feb 9, 2005
  4. Gordon
    Replies:
    3
    Views:
    310
    Steven Burn
    Apr 16, 2004
  5. Replies:
    0
    Views:
    97
Loading...

Share This Page