returning a value back to parent page from a popup page

K

knowdotnet

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.
 
E

Eliyahu Goldin

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.
 
L

Laurent Bugnion

Hi,

Eliyahu said:
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
 
K

knowdotnet

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
=================================================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top