returning a value back to parent page from a popup page

Discussion in 'ASP .Net' started by knowdotnet, Aug 27, 2006.

  1. knowdotnet

    knowdotnet Guest

    Hi all,

    Which is the best way to return a value back to the web page from a pop
    up page?
    I have a asp.net web application which opens a popup page on a link
    button click. The Link button is contained in a datagrid column. When i
    submit the popup page I want a value from the page to be returned to
    the parent page and is to be updated in a dataset, thereby updating the
    datagrid. I want the parent page to be refreshed on submitting the pop
    up page. i have used Javascript window.open method to open the popup
    page.
     
    knowdotnet, Aug 27, 2006
    #1
    1. Advertising

  2. knowdotnet

    Mark Rae Guest

    "Eliyahu Goldin" <> wrote in
    message news:...

    > The standard way of opening a popup is a showModalDialog call.


    So long as you're not interested about cross-browser compatibility...
     
    Mark Rae, Aug 27, 2006
    #2
    1. Advertising

  3. The standard way of opening a popup is a showModalDialog call. Then you can
    set window.returnValue property in the popup page and the calling page will
    get it as a return value from the showModalDialog call.

    After the call you can submit the form calling myForm.submit() method. This
    will fire a postback to the server for the calling page.

    window.open starts another browser window, it is not the same as a modal
    dialog.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    "knowdotnet" <> wrote in message
    news:...
    > Hi all,
    >
    > Which is the best way to return a value back to the web page from a pop
    > up page?
    > I have a asp.net web application which opens a popup page on a link
    > button click. The Link button is contained in a datagrid column. When i
    > submit the popup page I want a value from the page to be returned to
    > the parent page and is to be updated in a dataset, thereby updating the
    > datagrid. I want the parent page to be refreshed on submitting the pop
    > up page. i have used Javascript window.open method to open the popup
    > page.
    >
     
    Eliyahu Goldin, Aug 27, 2006
    #3
  4. Hi,

    Eliyahu Goldin wrote:
    > The standard way of opening a popup is a showModalDialog call. Then you can
    > set window.returnValue property in the popup page and the calling page will
    > get it as a return value from the showModalDialog call.


    Very non-standard. Works only in IE. You should really mention that when
    you give this kind of advice...


    > After the call you can submit the form calling myForm.submit() method. This
    > will fire a postback to the server for the calling page.
    >
    > window.open starts another browser window, it is not the same as a modal
    > dialog.


    Actually, it's very possible to open a modal window using window.open
    and the modal, dependent or dialog features (or a combination of these).
    Works in the Mozilla-family only.
    http://developer.mozilla.org/en/docs/DOM:window.open#Toolbar_and_chrome_features

    HTH,
    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    PhotoAlbum: http://www.galasoft-LB.ch/pictures
    Support children in Calcutta: http://www.calcutta-espoir.ch
     
    Laurent Bugnion, Aug 27, 2006
    #4
  5. knowdotnet

    knowdotnet Guest

    Thanks for the showModalDialog suggesion, I tried using the same, it
    worked fine.

    I am using the following code to open and return with the popup page.
    But one problem is only when the link button(a bound template column in
    the datagrid) is clicked twice the popup page opens, this happens only
    on the first time, othertimes the popup page opens on the first click
    itself.

    please give me more information on myForm.submit()


    ===========================================
    ' code to open a popup
    ' this is the code behind in the parent page
    ===========================================
    Private Sub dgConfig_ItemCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    dgConfig.ItemCommand


    Select Case e.Item.ItemType
    Case ListItemType.Item, ListItemType.AlternatingItem,
    ListItemType.EditItem
    CType(e.Item.FindControl("LinkButton2"),
    LinkButton).Attributes.Add("onclick", "var strReturn;
    strReturn=window.showModalDialog('childwin.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:yes');if
    (strReturn != null)
    document.getElementById('txtValue').value=strReturn;")

    End Select

    End Sub
    =================================================
     
    knowdotnet, Aug 28, 2006
    #5
  6. knowdotnet

    knowdotnet Guest

    can any one help me in this regard,
    thanks in advance


    knowdotnet wrote:
    > Thanks for the showModalDialog suggesion, I tried using the same, it
    > worked fine.
    >
    > I am using the following code to open and return with the popup page.
    > But one problem is only when the link button(a bound template column in
    > the datagrid) is clicked twice the popup page opens, this happens only
    > on the first time, othertimes the popup page opens on the first click
    > itself.
    >
    > please give me more information on myForm.submit()
    >
    >
    > ===========================================
    > ' code to open a popup
    > ' this is the code behind in the parent page
    > ===========================================
    > Private Sub dgConfig_ItemCommand(ByVal source As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    > dgConfig.ItemCommand
    >
    >
    > Select Case e.Item.ItemType
    > Case ListItemType.Item, ListItemType.AlternatingItem,
    > ListItemType.EditItem
    > CType(e.Item.FindControl("LinkButton2"),
    > LinkButton).Attributes.Add("onclick", "var strReturn;
    > strReturn=window.showModalDialog('childwin.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:yes');if
    > (strReturn != null)
    > document.getElementById('txtValue').value=strReturn;")
    >
    > End Select
    >
    > End Sub
    > =================================================
     
    knowdotnet, Sep 6, 2006
    #6
    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. mark
    Replies:
    1
    Views:
    599
  2. dapkniht
    Replies:
    1
    Views:
    1,389
    Eliyahu Goldin
    Mar 8, 2006
  3. Michael
    Replies:
    2
    Views:
    922
    Michael
    Sep 24, 2009
  4. Jens Peter Hansen
    Replies:
    7
    Views:
    594
    Randy Webb
    Jun 19, 2004
  5. Adrian  MacNair

    Parent to child back to parent

    Adrian MacNair, May 26, 2005, in forum: Javascript
    Replies:
    2
    Views:
    153
    Random
    May 26, 2005
Loading...

Share This Page