Command Button to Open Window

Discussion in 'ASP .Net Datagrid Control' started by Softworks, Jan 11, 2007.

  1. Softworks

    Softworks Guest

    I have a GridView that contains an command button in one of the columns.
    The code-behind does some processing of code and then needs to open a
    window.

    It looks like the postback fires before the PopUpWindow. Is there anyway
    around this?


    Private Sub dgJobs_CancelCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    dgJobs.CancelCommand

    -- code here to do some data manipulation

    Dim url As String = "Viewer.aspx?docName=" & JobID

    PopUpWindow(Url)

    End Sub

    Private Sub PopupWindow(ByVal url As String)

    Dim script As String = String.Format("<script
    language='javascript'>window.open('{0}', '_blank');</script>", url)

    RegisterStartupScript("OpenWindow", script)

    End Sub



    Thanks in advance!

    Tina
    Softworks, Jan 11, 2007
    #1
    1. Advertising

  2. Softworks

    Teemu Keiski Guest

    If you are indeed specifying the code to trigger the oipning of the window,
    it is natural that postbacking must happen first...

    Other ways:

    - Use UpdatePanel from ASP.NEt Ajax to "hide" the postback (if you use
    ASP.NET 2.0)
    .. Create & attach the opening script into onclick attribute of the rendered
    ImageButton when you could open the window without a postback. ,As you are
    taking some data from a datanound contro, (per row), you provbably could
    create the script in ItemDataBound event already.

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net


    "Softworks" <> wrote in message
    news:...
    >I have a GridView that contains an command button in one of the columns.
    >The code-behind does some processing of code and then needs to open a
    >window.
    >
    > It looks like the postback fires before the PopUpWindow. Is there anyway
    > around this?
    >
    >
    > Private Sub dgJobs_CancelCommand(ByVal source As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    > dgJobs.CancelCommand
    >
    > -- code here to do some data manipulation
    >
    > Dim url As String = "Viewer.aspx?docName=" & JobID
    >
    > PopUpWindow(Url)
    >
    > End Sub
    >
    > Private Sub PopupWindow(ByVal url As String)
    >
    > Dim script As String = String.Format("<script
    > language='javascript'>window.open('{0}', '_blank');</script>", url)
    >
    > RegisterStartupScript("OpenWindow", script)
    >
    > End Sub
    >
    >
    >
    > Thanks in advance!
    >
    > Tina
    >
    >
    Teemu Keiski, Jan 27, 2007
    #2
    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. Robert Mark Bram

    Open new command window for ANT task

    Robert Mark Bram, May 30, 2004, in forum: Java
    Replies:
    0
    Views:
    772
    Robert Mark Bram
    May 30, 2004
  2. Replies:
    0
    Views:
    494
  3. susan
    Replies:
    2
    Views:
    260
    susan
    Dec 14, 2006
  4. boriq
    Replies:
    4
    Views:
    567
    Tim Golden
    Jun 12, 2008
  5. PC HUA
    Replies:
    2
    Views:
    394
    PC HUA
    May 19, 2004
Loading...

Share This Page