This breaks this line from working properly
window.opener.document.forms["<%= strFormName %>"]......
How can I fix this and display the date into textbox after selecting the date from Calendar.aspx? This Very Urgent ..........................
If any body help me out
I have given the following Code
******************************
Code For :Master.master
******************************
Expand|Select|Wrap|Line Numbers
- <%@ Master Language="VB" CodeFile="Master.master.vb" Inherits="Pages_Master" %>
- <!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">
- </head>
- <body>
- <h1>Standard Header For All Pages</h1>
- <asp:ContentPlaceHolder id="CPH1" runat="server">
- </asp:ContentPlaceHolder>
- </body>
- </html>
Code For :PopUpCalendar.aspx
**************************************
This is a Cotent Page
--------------------------------
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="VB" MasterPageFile="Master.master" %>
- <script runat="server">
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
- End Sub
- </script>
- <asp:Content ID="Content1" ContentPlaceHolderId="CPH1" runat="server">
- <script type="text/javascript" language="Javascript">
- function GetDate(CtrlName)
- {/************ Use Javascript method (window.open) to PopUp a new window
- which contain a Calendar Control. In the meantime, we'll
- pass the Parent Form Name and Request Control Name in the QueryString!
- ******************/
- ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName='
- + CtrlName , "PopUpCalendar",
- "width=270,height=270,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
- }
- function CheckWindow()
- { ChildWindow.close(); }
- </script>
- <form id="Parent" runat="server">
- Start Date:
- <asp:TextBox id="txtStartDate" runat="server"></asp:TextBox>
- <%-- Pass in the Request Control Name, e.g. txtStartDate, into the Javascript method --%>
- <a href="javascript:GetDate('txtStartDate')">Select Date</a>
- <br />
- End Date:<asp:TextBox id="txtEndDate" runat="server"></asp:TextBox>
- <a href="javascript:GetDate('txtEndDate')">Select Date</a>
- </form>
- </asp:Content>
Code For :Calendar.aspx
*******************************
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="VB" %>
- <script runat="server">
- Public strFormName As String
- Public strCtrlName As String
- Public strSelectedDate As String
- Sub Page_Load(Sender As Object, E As EventArgs)
- If Not IsPostBack Then
- '-------------------------------------------------------------------
- ' Set the Calendar to Today's date in the first load
- '-------------------------------------------------------------------
- myCalendar.SelectedDate = System.DateTime.Now()
- '-------------------------------------------------------------------
- ' Set the DropDownList of Month and Year to Current Month and Year
- '-------------------------------------------------------------------
- ddlMonth.Items.FindByValue(DateTime.Now.Month).Selected = True
- ddlYear.SelectedValue = DateTime.Now.Year
- 'ddlYear.Items.FindByValue(DateTime.Now.Year).Selected = True
- End If
- '-------------------------------------------------------------------
- ' Set the Selected Date to a temp String
- ' Set FormName and Control Name to 2 String from the values in QueryString
- '-------------------------------------------------------------------
- strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy")
- strFormName = Request.QueryString("FormName")
- 'strFormName = "Parent"
- strCtrlName = Request.QueryString("CtrlName")
- 'strSelectContentId = Request.QueryString("ContentId")
- End Sub
- Sub myCalendar_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
- '-------------------------------------------------------------------
- ' Change the Temp Selected Date Object if change is made
- '-------------------------------------------------------------------
- strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy")
- End Sub
- Sub ddl_SelectedIndexChanged(ByVal Sender As Object, ByVal e As EventArgs)
- '-------------------------------------------------------------------
- ' Change the VisibleDate of the Calendar according to
- ' the DropDownList dynamically
- '-------------------------------------------------------------------
- myCalendar.VisibleDate = New DateTime(CInt(ddlYear.SelectedItem.Value), CInt(ddlMonth.SelectedItem.Value), 1)
- End Sub
- </script>
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head>
- <script type="text/javascript" language="Javascript">
- function ReturnDate()
- {window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"].value = "<%= strSelectedDate %>";
- window.close();
- }
- function Close()
- {
- window.close();
- }
- </script>
- </head>
- <body>
- <form id="Form1" runat="server">
- <table>
- <tr>
- <td align="Center">
- Month:
- <asp:DropDownList id="ddlMonth" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="True">
- <asp:ListItem Value="1">January</asp:ListItem>
- <asp:ListItem Value="2">February</asp:ListItem>
- <asp:ListItem Value="3">March</asp:ListItem>
- <asp:ListItem Value="4">April</asp:ListItem>
- <asp:ListItem Value="5">May</asp:ListItem>
- <asp:ListItem Value="6">June</asp:ListItem>
- <asp:ListItem Value="7">July</asp:ListItem>
- <asp:ListItem Value="8">August</asp:ListItem>
- <asp:ListItem Value="9">September</asp:ListItem>
- <asp:ListItem Value="10">October</asp:ListItem>
- <asp:ListItem Value="11">November</asp:ListItem>
- <asp:ListItem Value="12">December</asp:ListItem>
- </asp:DropDownList>
-
- Year:
- <asp:DropDownList id="ddlYear" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="True">
- <asp:ListItem Value="2001">2001</asp:ListItem>
- <asp:ListItem Value="2002">2002</asp:ListItem>
- <asp:ListItem Value="2003">2003</asp:ListItem>
- <asp:ListItem Value="2004">2004</asp:ListItem>
- <asp:ListItem Value="2005">2005</asp:ListItem>
- <asp:ListItem>2006</asp:ListItem>
- <asp:ListItem>2007</asp:ListItem>
- <asp:ListItem>2008</asp:ListItem>
- <asp:ListItem>2009</asp:ListItem>
- </asp:DropDownList>
- </td>
- </tr>
- <tr>
- <td align="Center">
- <asp:Calendar id="myCalendar" runat="server" BorderWidth="1px" BackColor="#FFFFCC" Width="239px" DayNameFormat="FirstLetter" ForeColor="#663399" Height="200px" Font-Size="8pt" Font-Names="Verdana" BorderColor="#FFCC66" ShowGridLines="True" OnSelectionChanged="myCalendar_SelectionChanged">
- <SelectorStyle backcolor="#FFCC66"></SelectorStyle>
- <NextPrevStyle font-size="9pt" forecolor="#FFFFCC"></NextPrevStyle>
- <DayHeaderStyle height="1px" backcolor="#FFCC66"></DayHeaderStyle>
- <SelectedDayStyle font-bold="True" backcolor="#CCCCFF"></SelectedDayStyle>
- <TitleStyle font-size="9pt" font-bold="True" forecolor="#FFFFCC" backcolor="#990000"></TitleStyle>
- <OtherMonthDayStyle forecolor="#CC9966"></OtherMonthDayStyle>
- </asp:Calendar>
- </td>
- </tr>
- <tr>
- <td align="Center">
- <input id="btnReturnDate" onclick="javascript:ReturnDate()" type="button" value="Select" runat="Server" />
- <input id="btnCloseWindow" onclick="javascript:Close()" type="button" value="Close" runat="Server" /></td>
- </tr>
- </table>
- </form>
- </body>
- </html>