Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help opening new browser and retrieve results

Status
Not open for further replies.

Salthead

Programmer
Feb 25, 2003
7
US
I'm trying to open a new browser window, allow the user to select a date, pass the date back to a textbox on the parent window, and close the child. Everything seems to work fine except the textbox does not get filled with the date. What am I missing? Is there a better way that this method? Examples are always welcome.

ParentWindow.aspx:
<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;ParentWindow.aspx.vb&quot; Inherits=&quot;PopUpCalendar.WebForm1&quot;%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content=&quot;Microsoft Visual Studio.NET 7.0&quot; name=&quot;GENERATOR&quot;>
<meta content=&quot;Visual Basic 7.0&quot; name=&quot;CODE_LANGUAGE&quot;>
<meta content=&quot;JavaScript&quot; name=&quot;vs_defaultClientScript&quot;>
<meta content=&quot; name=&quot;vs_targetSchema&quot;>
</HEAD>
<body MS_POSITIONING=&quot;GridLayout&quot;>
<form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<asp:button id=&quot;btnPopUp&quot; style=&quot;Z-INDEX: 101; LEFT: 182px; POSITION: absolute; TOP: 138px&quot; runat=&quot;server&quot; Text=&quot;Button&quot;></asp:button>
<asp:TextBox id=&quot;txtDate&quot; style=&quot;Z-INDEX: 102; LEFT: 300px; POSITION: absolute; TOP: 140px&quot; runat=&quot;server&quot; Width=&quot;189px&quot; Height=&quot;30px&quot;></asp:TextBox></form>
</body>
</HTML>

ParentWindow.aspx.vb:

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents txtDate As System.Web.UI.WebControls.TextBox
Protected WithEvents btnPopUp As System.Web.UI.WebControls.Button

#Region &quot; Web Form Designer Generated Code &quot;

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub btnPopUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPopUp.Click
Dim strFeatures As String
Dim strScript As String
Dim strURL As String = &quot;ChildWindow.aspx&quot;

strFeatures = &quot;'height=320;width=320;'&quot;

strScript = &quot;<script language=javascript>&quot;
strScript &= &quot;window.open('&quot; & strURL & &quot;','',&quot; & strFeatures & &quot;);&quot;
strScript &= &quot;</script>&quot;
Response.Write(strScript)

End Sub
End Class

ChildWindow.aspx:

<%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; Codebehind=&quot;ChildWindow.aspx.vb&quot; Inherits=&quot;PopUpCalendar.ChildWindow&quot;%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<HTML>
<HEAD>
<title>ChildWindow</title>
<meta content=&quot;Microsoft Visual Studio.NET 7.0&quot; name=&quot;GENERATOR&quot;>
<meta content=&quot;Visual Basic 7.0&quot; name=&quot;CODE_LANGUAGE&quot;>
<meta content=&quot;JavaScript&quot; name=&quot;vs_defaultClientScript&quot;>
<meta content=&quot; name=&quot;vs_targetSchema&quot;>
</HEAD>
<body MS_POSITIONING=&quot;GridLayout&quot;>
<form id=&quot;Form1&quot; method=&quot;post&quot; runat=&quot;server&quot;>
<asp:Calendar id=&quot;Calendar1&quot; style=&quot;Z-INDEX: 101; LEFT: 131px; POSITION: absolute; TOP: 96px&quot; runat=&quot;server&quot;></asp:Calendar></form>
</body>
</HTML>

ChildWindow.aspx.vb:

Public Class ChildWindow
Inherits System.Web.UI.Page
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar

#Region &quot; Web Form Designer Generated Code &quot;

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Dim strScript As String
Dim strDate As String = Calendar1.SelectedDate

strScript = &quot;<script language=javascript>&quot;
strScript &= &quot;window.opener.form1.txtDate.text ='&quot;
strScript &= strDate & &quot;';&quot;
strScript &= &quot;window.close();&quot;
strScript &= &quot;</script>&quot;
Response.Write(strScript)
End Sub
End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top