473,748 Members | 8,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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.d ocument.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 8484
Frinavale
9,735 Recognized Expert Moderator Expert
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.d ocument.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 = "YourAspFormNam e")


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
2565
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 the Master Page event, in its place IntelliSense shows me a Delegate Sub EventHandler. I am new with events managements, so any help and guiadance will be appreciated. Federico
2
7022
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 header. I tried to put the link tag in the Master page, but the classes are not recognized in the Content Page. How do I use a StyleSheet with the Content Page? TIA
4
3016
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. here is the javascript produced: <script>window.opener.document.forms.txtEndDate.value = '7/15/2006';self.close()</script> I basically need to populate txtEndDate on the content page. if
7
8728
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 remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
0
2115
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 sets a connection string to the database. The content page has a simple gridview that should show records from the selected database. Initial content page displays data from correct place. first change of dropdownlist correctly updates content...
3
6356
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 page so that this will be displayed on all the content pages automatically. This works fine for the content pages that are stored in the same
8
13535
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" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1
1214
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: <script>window.opener.aspnetForm.ctl00_ContentPlaceHolderMain_txtCM.value='7/15/2006';self.close()</script> I basically need to populate txtCM on the content page. When you look at the source of your content page the control is renamed as...
2
5372
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 http://weblogs.asp.net/scottgu/archive/2007/07/09/vs-2008-nested-master-page-support.aspx ) .. I have a 'Main' master and added a 'Sub' master (based on 'Main') and finally added a 'Home' content page (based on 'Sub'). However rather than the expected Content Placeholder control the content page has a comment
0
8984
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9238
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8237
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.