473,386 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Populate Calender From Content Page Using Master Page in asp.net 2.0

When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm
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
  1. <%@ Master Language="VB" CodeFile="Master.master.vb" Inherits="Pages_Master" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" >
  5. <head runat="server">
  6. </head>
  7. <body>
  8. <h1>Standard Header For All Pages</h1>
  9. <asp:ContentPlaceHolder id="CPH1" runat="server">
  10.  
  11. </asp:ContentPlaceHolder>
  12. </body>
  13. </html>
  14.  
**************************************
Code For :PopUpCalendar.aspx
**************************************
This is a Cotent Page
--------------------------------
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" MasterPageFile="Master.master" %>
  2.  
  3. <script runat="server">
  4.  
  5. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  6.  
  7. End Sub
  8. </script>
  9.  
  10. <asp:Content ID="Content1" ContentPlaceHolderId="CPH1" runat="server">
  11. <script type="text/javascript" language="Javascript">    
  12. function GetDate(CtrlName)
  13. {/************ Use Javascript method (window.open) to PopUp a new window 
  14.   which contain a Calendar Control. In the meantime, we'll 
  15.   pass the Parent Form Name and Request Control Name in the QueryString! 
  16.   ******************/
  17.   ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' 
  18.                 + CtrlName , "PopUpCalendar", 
  19.                 "width=270,height=270,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
  20.  }   
  21.  function CheckWindow()
  22.    {  ChildWindow.close();   }
  23. </script>
  24. <form id="Parent" runat="server">
  25. Start Date:
  26. <asp:TextBox id="txtStartDate" runat="server"></asp:TextBox>
  27. <%-- Pass in the Request Control Name, e.g. txtStartDate, into the Javascript method --%>
  28. <a href="javascript:GetDate('txtStartDate')">Select Date</a>
  29. <br />
  30. End Date:<asp:TextBox id="txtEndDate" runat="server"></asp:TextBox>        
  31. <a href="javascript:GetDate('txtEndDate')">Select Date</a>
  32. </form>
  33. </asp:Content>
  34.  
******************************
Code For :Calendar.aspx
*******************************
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" %>
  2. <script runat="server">
  3.     Public strFormName As String
  4.     Public strCtrlName As String
  5.     Public strSelectedDate As String
  6.  
  7.     Sub Page_Load(Sender As Object, E As EventArgs)
  8.         If Not IsPostBack Then
  9.             '-------------------------------------------------------------------
  10.             ' Set the Calendar to Today's date in the first load
  11.             '-------------------------------------------------------------------
  12.             myCalendar.SelectedDate = System.DateTime.Now()
  13.             '-------------------------------------------------------------------
  14.             ' Set the DropDownList of Month and Year to Current Month and Year
  15.             '-------------------------------------------------------------------
  16.             ddlMonth.Items.FindByValue(DateTime.Now.Month).Selected = True
  17.             ddlYear.SelectedValue = DateTime.Now.Year
  18.             'ddlYear.Items.FindByValue(DateTime.Now.Year).Selected = True
  19.         End If
  20.         '-------------------------------------------------------------------
  21.         ' Set the Selected Date to a temp String
  22.         ' Set FormName and Control Name to 2 String from the values in QueryString
  23.         '-------------------------------------------------------------------
  24.         strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy")
  25.         strFormName = Request.QueryString("FormName")
  26.         'strFormName = "Parent"
  27.         strCtrlName = Request.QueryString("CtrlName")
  28.         'strSelectContentId = Request.QueryString("ContentId")
  29.     End Sub
  30.     Sub myCalendar_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
  31.         '-------------------------------------------------------------------
  32.         ' Change the Temp Selected Date Object if change is made
  33.         '-------------------------------------------------------------------
  34.         strSelectedDate = myCalendar.SelectedDate.ToString("dd/MM/yyyy")
  35.     End Sub
  36.     Sub ddl_SelectedIndexChanged(ByVal Sender As Object, ByVal e As EventArgs)
  37.         '-------------------------------------------------------------------
  38.         ' Change the VisibleDate of the Calendar according to 
  39.         ' the DropDownList dynamically
  40.         '-------------------------------------------------------------------
  41.         myCalendar.VisibleDate = New DateTime(CInt(ddlYear.SelectedItem.Value), CInt(ddlMonth.SelectedItem.Value), 1)
  42.     End Sub
  43. </script>
  44. <html xmlns="http://www.w3.org/1999/xhtml" >
  45. <head>
  46.     <script type="text/javascript" language="Javascript">
  47.     function ReturnDate()
  48.         {window.opener.document.forms["<%= strFormName %>"].elements["<%= strCtrlName %>"].value = "<%= strSelectedDate %>";
  49.          window.close();
  50.         }
  51.    function Close()
  52.        {
  53.          window.close();
  54.        }
  55. </script>
  56. </head>
  57. <body>
  58.     <form id="Form1" runat="server">
  59.         <table>
  60.             <tr>
  61.                 <td align="Center">
  62.                     Month:
  63.                     <asp:DropDownList id="ddlMonth" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="True">
  64.                         <asp:ListItem Value="1">January</asp:ListItem>
  65.                         <asp:ListItem Value="2">February</asp:ListItem>
  66.                         <asp:ListItem Value="3">March</asp:ListItem>
  67.                         <asp:ListItem Value="4">April</asp:ListItem>
  68.                         <asp:ListItem Value="5">May</asp:ListItem>
  69.                         <asp:ListItem Value="6">June</asp:ListItem>
  70.                         <asp:ListItem Value="7">July</asp:ListItem>
  71.                         <asp:ListItem Value="8">August</asp:ListItem>
  72.                         <asp:ListItem Value="9">September</asp:ListItem>
  73.                         <asp:ListItem Value="10">October</asp:ListItem>
  74.                         <asp:ListItem Value="11">November</asp:ListItem>
  75.                         <asp:ListItem Value="12">December</asp:ListItem>
  76.                     </asp:DropDownList>
  77.                     &nbsp;
  78.                     Year:
  79.                     <asp:DropDownList id="ddlYear" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="True">
  80.                         <asp:ListItem Value="2001">2001</asp:ListItem>
  81.                         <asp:ListItem Value="2002">2002</asp:ListItem>
  82.                         <asp:ListItem Value="2003">2003</asp:ListItem>
  83.                         <asp:ListItem Value="2004">2004</asp:ListItem>
  84.                         <asp:ListItem Value="2005">2005</asp:ListItem>
  85.                         <asp:ListItem>2006</asp:ListItem>
  86.                         <asp:ListItem>2007</asp:ListItem>
  87.                         <asp:ListItem>2008</asp:ListItem>
  88.                         <asp:ListItem>2009</asp:ListItem>
  89.               </asp:DropDownList>
  90.           </td>
  91.             </tr>
  92.             <tr>
  93.                 <td align="Center">
  94.                     <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">
  95.                         <SelectorStyle backcolor="#FFCC66"></SelectorStyle>
  96.                         <NextPrevStyle font-size="9pt" forecolor="#FFFFCC"></NextPrevStyle>
  97.                         <DayHeaderStyle height="1px" backcolor="#FFCC66"></DayHeaderStyle>
  98.                         <SelectedDayStyle font-bold="True" backcolor="#CCCCFF"></SelectedDayStyle>
  99.                         <TitleStyle font-size="9pt" font-bold="True" forecolor="#FFFFCC" backcolor="#990000"></TitleStyle>
  100.                         <OtherMonthDayStyle forecolor="#CC9966"></OtherMonthDayStyle>
  101.                     </asp:Calendar>
  102.                 </td>
  103.             </tr>
  104.             <tr>
  105.                 <td align="Center">
  106.                     <input id="btnReturnDate" onclick="javascript:ReturnDate()" type="button" value="Select" runat="Server" />&nbsp; &nbsp;
  107.                     <input id="btnCloseWindow" onclick="javascript:Close()" type="button" value="Close" runat="Server" /></td>
  108.             </tr>
  109.         </table>
  110.     </form>
  111. </body>
  112. </html>
Jan 11 '08 #1
1 8443
Frinavale
9,735 Expert Mod 8TB
When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm
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 ..........................
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="VB" %>
  2. <script runat="server">
  3.     Public strFormName As String
  4.     Public strCtrlName As String
  5.     Public strSelectedDate As String
You've declared strFormName, but have not set it to a value.
(Set strFromName = "YourAspFormName")


Aside:
Check this out ...it's a free pop up calendar...and it works very nicely (click on the month, it'll show months in the yaer...then click on the year...it'll show years)

-Frinny
Jan 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Federico | last post by:
I have a problem, I have an event declared in a Master Page, and I want to use in a Content Page holder of a Content Page. When I want to create the method to handle the event, I can njot reference...
2
by: SR | last post by:
I have started a web site using ASP.NET 2.0. I would like to centralize all of my classes in a StyleSheet but I cannot figure out how to link the StyleSheet to a Content Page since there is no...
4
by: Mori | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. This code works if no masterpage is involved. ...
7
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will...
0
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and...
3
by: vikramp | last post by:
Hi, I am still new to ASP.NET 2.0 and trying to develope something using Master pages. My problem is: I have a master page that contains Logo image and a navigation menu at the top of the...
8
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB"...
1
by: rjainx | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. here is the javascript produced: ...
2
by: John | last post by:
Hi, I'm having trouble with nested master pages (and creating the same behaviour as Scott Guthrie's blog post...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.