Hi,
Base on your description, you want to pop out a clalender when you click on the textbox, and close the calender page after you chose the data in the content page, right?
Because you use the master page, you should use the control's clientid when you use getElementById
Below is my sample code,
1. The master page:
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage_MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" method=post>
<table>
<tr>
<td align="right">
Start Date:
</td>
<td align="left">
</td>
<td align="center">
</td>
</tr>
<tr>
<td align="right">
End Date:
</td>
<td align="left">
</td>
<td align="center">
</td>
</tr>
</table>
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
2. The content page:
<%@ Page Language="VB" MasterPageFile="~/MasterPage/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="MasterPage_Default" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:TextBox ID="TextBox1" runat="server" onclick="window.open('../popup.aspx?textbox=ctl00$txtStartDate','cal','width=250,height=225,left=270,top=180')"></asp:TextBox>
</asp:Content>
3. The calender page:
<%@ Page Language="vb" AutoEventWireup="false" Src="PopUp.aspx.vb" Inherits="DotNetJohn.PopUp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>PopUp</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Calendar ID="calDate" OnSelectionChanged="Change_Date" Runat="server" />
<input type="hidden" id="control" runat="server" />
</form>
</body>
</html>
4. The codebehind of the calender page:
Imports System.Web.UI.HtmlControls.HtmlGenericControl
Namespace DotNetJohn
Public Class PopUp
Inherits System.Web.UI.Page
Protected WithEvents control As System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents calDate As System.Web.UI.WebControls.Calendar
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
control.Value = Request.QueryString("textbox").ToString()
End Sub
Protected Sub Change_Date(sender As System.Object, e As System.EventArgs)
Dim strScript As String = "<script>window.opener.document.forms(0)." + control.Value + ".value = '"
strScript += calDate.SelectedDate.ToString("MM/dd/yyyy")
strScript += "';self.close()"
strScript += "</" + "script>"
RegisterClientScriptBlock("anything", strScript)
End Sub
End Class
End Namespace
storm721984: The problem i face is once i select a date on the calender it just doesn't seem to close and no value is return on two of the textbox located inside Calender3.aspx
About your problem, your refer the calender's codebehind.
Hope it helps.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Yours sincerely,
Amanda Wang
Microsoft Online Community Support