How to capture the date selected in a pop up
-
Hi, I have a web page where clicking on a button I am opening another web form using window.open function. Now I want to know how to capture the date selected by the user and put it in the parent web form. Regards, Rocky
Rakesh
hi.... You can do that using
window.opener
in javascript Example.... 1.htmlvar anotherwindow=window.open("2.html") //change the background color of the second window from main anotherwindow.bgColor="black"
2.htmlSecondary window
Regards, Sandeep Kumar.V -
Hi, I have a web page where clicking on a button I am opening another web form using window.open function. Now I want to know how to capture the date selected by the user and put it in the parent web form. Regards, Rocky
Rakesh
-
The child form has a concept of the parent. You can access controls on the parent form via javascript. In javascript you would do something like this:
self.opener.document.forms[0].parentControl.Value = childControl.value;
Hope that helps. Ben
-
Thanks for the response. Where you want me to put this code in the child page. I mean in which event?
Rakesh
Here is some vb.net code I wrote a while back. I had the user press a save button that did a post back and then called this method:
Private Sub closewindow(ByVal indate As Date)
Dim myScript As New StringBuilder
With myScript
.Append("")
.Append(Environment.NewLine)
'This code sets the correct field on the opener form
Dim tmpstr As String = "self.opener.document.forms[0]." + CStr(Session("DatelookupField"))
.Append(tmpstr)
.Append(".value = """)
.Append(indate.ToShortDateString)
.Append("""")
.Append(Environment.NewLine)
'focus the opener form
.Append("self.opener.focus()")
.Append(Environment.NewLine)
'Close the calendar window
.Append("self.close()")
.Append(Environment.NewLine)
.Append("")
Page.RegisterStartupScript("close window", .ToString())
End With
End SubAll this code is .net 1.1 I set a session variable in the parent form so I knew what the control name was to pass the date back to the parent form. Hope that helps. Ben