Initiating a PostBack on a main window from a popup window

Discussion in 'ASP .Net' started by Jay, Nov 18, 2003.

  1. Jay

    Jay Guest

    I have a situation where the user clicks on a button in a
    DataGrid to launch a popup window via javascript. In the
    popup window the user does some things that result in
    changes to the underlying database the DataGrid is using
    as a data source. When the popup window is closed I want
    to refresh the main window -- i.e., cause a postback to
    happen.

    Is this possible?

    From a user-interface perspective the popup window works
    very nice. I know that I could perform the same funtion
    in the main window but that would be messy.

    Jay
     
    Jay, Nov 18, 2003
    #1
    1. Advertising

  2. If you get the window.opener object (also a window) you can use the
    window.location.reload before you close the popup window.

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Shell/UI
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "Jay" <> wrote in message
    news:012501c3ae02$b6067530$...
    > I have a situation where the user clicks on a button in a
    > DataGrid to launch a popup window via javascript. In the
    > popup window the user does some things that result in
    > changes to the underlying database the DataGrid is using
    > as a data source. When the popup window is closed I want
    > to refresh the main window -- i.e., cause a postback to
    > happen.
    >
    > Is this possible?
    >
    > From a user-interface perspective the popup window works
    > very nice. I know that I could perform the same funtion
    > in the main window but that would be messy.
    >
    > Jay
     
    Chris Jackson, Nov 18, 2003
    #2
    1. Advertising

  3. Jay

    Teemu Keiski Guest

    If the grid on main window is just populated when the page loads, you just
    call opener.location.reload() (javascript call) on pop-up and cause it to
    reload the main page.

    However, if it needs more work, i.e a postback like some button would have
    caused it (say Button) and an event to handle, you could have a hidden
    button control on main window:

    <asp:Button ID="btnHidden" runat="server" />

    and then an associated javascript function for it (also on main window)

    function myPostBack()
    {
    <%=Page.GetPostBackEventReference(btnHidden,'')%>
    }

    This causes a postback event to be raised in behalf of the Button, when
    myPostBAck is called. You could then call this on the pop-up window by:

    opener.myPostBack();

    and it causes the main window to be posted as if btnHidden would have been
    clicked. So to handle this click you need to handle btnHidden's Click event.
    of course, if you already have a Button (or other control) that does this,
    you could cause the postback on behalf of it as well.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist


    "Jay" <> wrote in message
    news:012501c3ae02$b6067530$...
    > I have a situation where the user clicks on a button in a
    > DataGrid to launch a popup window via javascript. In the
    > popup window the user does some things that result in
    > changes to the underlying database the DataGrid is using
    > as a data source. When the popup window is closed I want
    > to refresh the main window -- i.e., cause a postback to
    > happen.
    >
    > Is this possible?
    >
    > From a user-interface perspective the popup window works
    > very nice. I know that I could perform the same funtion
    > in the main window but that would be messy.
    >
    > Jay
     
    Teemu Keiski, Nov 18, 2003
    #3
  4. Jay

    Teemu Keiski Guest

    Note that for the Button to be hidden, it should have Visible="False" as
    well. :)

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "Teemu Keiski" <> wrote in message
    news:%...
    > If the grid on main window is just populated when the page loads, you just
    > call opener.location.reload() (javascript call) on pop-up and cause it to
    > reload the main page.
    >
    > However, if it needs more work, i.e a postback like some button would have
    > caused it (say Button) and an event to handle, you could have a hidden
    > button control on main window:
    >
    > <asp:Button ID="btnHidden" runat="server" />
    >
    > and then an associated javascript function for it (also on main window)
    >
    > function myPostBack()
    > {
    > <%=Page.GetPostBackEventReference(btnHidden,'')%>
    > }
    >
    > This causes a postback event to be raised in behalf of the Button, when
    > myPostBAck is called. You could then call this on the pop-up window by:
    >
    > opener.myPostBack();
    >
    > and it causes the main window to be posted as if btnHidden would have been
    > clicked. So to handle this click you need to handle btnHidden's Click

    event.
    > of course, if you already have a Button (or other control) that does this,
    > you could cause the postback on behalf of it as well.
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    >
    > "Jay" <> wrote in message
    > news:012501c3ae02$b6067530$...
    > > I have a situation where the user clicks on a button in a
    > > DataGrid to launch a popup window via javascript. In the
    > > popup window the user does some things that result in
    > > changes to the underlying database the DataGrid is using
    > > as a data source. When the popup window is closed I want
    > > to refresh the main window -- i.e., cause a postback to
    > > happen.
    > >
    > > Is this possible?
    > >
    > > From a user-interface perspective the popup window works
    > > very nice. I know that I could perform the same funtion
    > > in the main window but that would be messy.
    > >
    > > Jay

    >
    >
     
    Teemu Keiski, Nov 18, 2003
    #4
  5. Jay

    vMike Guest

    You may also just be able to just call the javascript postback that asp.net
    creates using
    __doPostBack("yourobjectname","") within your own javascript.

    "Jay" <> wrote in message
    news:012501c3ae02$b6067530$...
    > I have a situation where the user clicks on a button in a
    > DataGrid to launch a popup window via javascript. In the
    > popup window the user does some things that result in
    > changes to the underlying database the DataGrid is using
    > as a data source. When the popup window is closed I want
    > to refresh the main window -- i.e., cause a postback to
    > happen.
    >
    > Is this possible?
    >
    > From a user-interface perspective the popup window works
    > very nice. I know that I could perform the same funtion
    > in the main window but that would be messy.
    >
    > Jay
     
    vMike, Nov 19, 2003
    #5
  6. Jay

    Teemu Keiski Guest

    Definately, but only when there is at least one control at the Page that
    requires this JavaScript to exist. A call to Page.GetPostBackEventReference
    ensures that __doPostBack declaration is outputted (that's what the control
    needing this declaration calls)

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist

    "vMike" <> wrote in message
    news:bpfrkg$9a0$...
    > You may also just be able to just call the javascript postback that

    asp.net
    > creates using
    > __doPostBack("yourobjectname","") within your own javascript.
    >
    > "Jay" <> wrote in message
    > news:012501c3ae02$b6067530$...
    > > I have a situation where the user clicks on a button in a
    > > DataGrid to launch a popup window via javascript. In the
    > > popup window the user does some things that result in
    > > changes to the underlying database the DataGrid is using
    > > as a data source. When the popup window is closed I want
    > > to refresh the main window -- i.e., cause a postback to
    > > happen.
    > >
    > > Is this possible?
    > >
    > > From a user-interface perspective the popup window works
    > > very nice. I know that I could perform the same funtion
    > > in the main window but that would be messy.
    > >
    > > Jay

    >
    >
     
    Teemu Keiski, Nov 20, 2003
    #6
  7. Jay

    maya_zakry

    Joined:
    Sep 21, 2006
    Messages:
    2
    my pop up needs refresh

    hi,

    this topic is really really close to what im trying to accomplish, hei, teemu, ive downloaded your sample and follow ur intruction but to no avail. maybe i didnt find a way to apply it to my situation, so here;s my code (in po up)

    strItemID = CType(lbtnItemID.Text.Trim(), String)

    strJavaScript &= "window.opener.PostBackOnMainPage();" & _
    HttpContext.Current.Request.QueryString("objFindItemID") & ".value = '" & _
    strItemID.Trim & "';window.close();"
    strJavaScript = strJavaScript & "</script" & ">"
    Literal1.Text = strJavaScript


    if u see the window.opener.PostBackOnMainPage(), i already apply it, but still get errors, pliz help...

    thanks and sorry for my poor english
     
    maya_zakry, Sep 21, 2006
    #7
  8. Jay

    maya_zakry

    Joined:
    Sep 21, 2006
    Messages:
    2
    fast solution

    okay, ive found another way of doing this, this suits my situation very well, just by adding this line in my window.opener :-

    window.opener.document.forms(0).submit();
     
    maya_zakry, Sep 28, 2006
    #8
  9. Jay

    livshitz

    Joined:
    Jun 12, 2011
    Messages:
    1
    livshitz, Jun 12, 2011
    #9
    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. Pavils Jurjans

    ASP page initiating complex code execution

    Pavils Jurjans, Feb 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    371
    Tommy
    Feb 3, 2004
  2. Replies:
    1
    Views:
    361
    souri challa
    Jul 8, 2005
  3. sentinel
    Replies:
    1
    Views:
    173
    kaeli
    Feb 16, 2004
  4. Jens Peter Hansen
    Replies:
    7
    Views:
    560
    Randy Webb
    Jun 19, 2004
  5. Jimmy
    Replies:
    3
    Views:
    459
    Henry
    Aug 16, 2007
Loading...

Share This Page