473,221 Members | 1,988 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,221 software developers and data experts.

Problem with a custom calendar control

First, let me start by saying my asp.net experience is still in it's
infancy so please bare with me as I try to explain my situation.

I have created a single page that with the use of many controls (i.e.
roundedcorners component [see www.4guysfromrolla.com], buttons and
panels) functions like a tab control. The buttons are
programmatically designed to make the corresponding panel visible.

Sample aspx.vb code:

Private Sub btnEvent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnEvent.Click

pnlEvent.Visible = True
pnlHotel.Visible = False
pnlTravel.Visible = False
pnlPerDiem.Visible = False
pnlOther.Visible = False

End Sub

Private Sub btnHotel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnHotel.Click

pnlHotel.Visible = True
If chkhSpouse.Checked = True Then
pnlSpouseData.Visible = True
Else
pnlSpouseData.Visible = False
End If

If chkhCCHold.Checked = True Then
txthCCHoldAmt.Visible = True
lblhCCHoldAmt.Visible = True
Else
txthCCHoldAmt.Visible = False
lblhCCHoldAmt.Visible = False
End If
pnlTravel.Visible = False
pnlPerDiem.Visible = False
pnlOther.Visible = False
pnlEvent.Visible = False

End Sub

Private Sub btnTravel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnTravel.Click

pnlEvent.Visible = False
pnlHotel.Visible = False
pnlTravel.Visible = True
pnlPerDiem.Visible = False
pnlOther.Visible = False

End Sub

Private Sub btnPerDiem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnPerDiem.Click

pnlEvent.Visible = False
pnlHotel.Visible = False
pnlTravel.Visible = False
pnlPerDiem.Visible = True
pnlOther.Visible = False

End Sub

Private Sub btnOther_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnOther.Click

pnlEvent.Visible = False
pnlHotel.Visible = False
pnlTravel.Visible = False
pnlPerDiem.Visible = False
pnlOther.Visible = True

End Sub

On each of these panels there are buttons that link to a calendar
control (Calendar.aspx). Each button passes a textbox name to the
calendar control so that when a date is selected this value is passed
back to the corresponding text box.

Sample Button HTML Code:

<SPAN id="calBlock1"><A
href="javascript:calendar_window=window.open('//localhost/advtravel/calendar.aspx?

formname=AdminBooking.txteStartDt','calendar_windo w','width=230,height=230');calendar_window.focus() "><IMG
id="eStartDtCal" height="22" alt="Choose an event start date"
src="images/calendar.gif" align="absMiddle" border="0"></A></SPAN>

Sample Calendar.aspx HTML:

<%@ Register TagPrefix="cc1" Namespace="PrettyUI" Assembly="PrettyUI"
%>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Calendar.aspx.vb" smartnavigation="true"
Inherits="AdvTravel.Calendar" %>
<HTML>
<HEAD>
<title>Select a date</title>
<script runat="server">
Private Sub cntCalendar_SelectionChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cntCalendar.SelectionChanged
Dim strjscript As String = "<script language=""javascript"">"
strjscript = strjscript & "window.opener." &
HttpContext.Current.Request.QueryString("formname" ) & ".value = '" &
cntCalendar.SelectedDate & "';window.close();"
strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool
Bug
Literal1.Text = strjscript

End Sub
</script>
<asp:literal id="Literal1" Runat="server"></asp:literal>
<LINK href="http://localhost/AdvTravel/CSS/calendar.css"
type="text/css" rel="stylesheet">
</HEAD>
<BODY bgcolor="silver">
<form id="frmCalendar" runat="server">
<cc1:roundedcorners id="RoundedCorners1" runat="server"
Width="210px" BorderColor="Navy" BorderStyle="Solid"
BorderWidth="2px" CornerHeight="20px" CornerWidth="20px"
Height="210px" BackColor="WhiteSmoke">
<TABLE cellSpacing="0" cellPadding="0">
<TR>
<TD height="13">
<asp:dropdownlist id="drpCalMonth" Runat="Server" Width="100px"
CssClass="calTitle" OnSelectedIndexChanged="Set_Calendar"
AutoPostBack="True"></asp:dropdownlist>
<asp:dropdownlist id="drpCalYear" Runat="Server" Width="60px"
CssClass="calTitle" OnSelectedIndexChanged="Set_Calendar"
AutoPostBack="True"></asp:dropdownlist></TD>
</TR>
<TR>
<TD>
<asp:calendar id="cntCalendar" Runat="Server" Width="100%"
CssClass="calbody" ondayrender="Calendar_dayrender"
ShowTitle="True"
OnSelectionChanged="cntCalendar_SelectionChanged"
OtherMonthDayStyle-BackColor="White"
DayStyle-BackColor="LightYellow"></asp:calendar></TD>
</TR>
</TABLE>
</cc1:roundedcorners></form>
</BODY>
</HTML>

This functionality works well on the first visible panel on the page
however, soon as I click on a new "tab" to make a different panel
visible the the calendar functionality no longer works. The calendar
will pop-up but when a date is selected the calendar.aspx pop-up does
not close and does not write the value back to the corresponding text
field.

NOTE: There is a animated .gif on the page that also hangs when the
javascript fails.

I must conclude with first, an apology for the long-winded
explaination to my problem and second, a thank you in advance to
anyone willing to assist a newbie in trying to find a fix to this
problem.
Nov 18 '05 #1
2 3378
I know that IE stops animating a gif when it considers the page submitted. I
think that javascript continues to run until the page hits its unload stage.
So I'm not sure why javascript stops for you.

May I make a suggestion for an entirely different approach? ASP.NET has a
very rich collection of third party controls for almost anything you'd like.
Some are even free. In fact, the date entry controls segment has around 20
items to offer, plus several articles posted on popular ASP.NET sites. With
date controls, most offer a popup calendar that avoids the second window
(which is usually blocked by popup blockers and has other UI shortcomings).
Instead, they use lots of javascript to show and hide a TABLE or DIV
containing a calendar that does not post back each time you click. (The
ASP.NET calendar always posts back.) The third party controls can be found
on these sites: www.asp.net Control Gallery, www.123aspx.com, and
www.411asp.net. I am the author of one, "Peter's Date Package",
http://www.peterblum.com/datecontrols/home.aspx.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Caesar Augustus" <ma*******@yahoo.com> wrote in message
news:92**************************@posting.google.c om...
First, let me start by saying my asp.net experience is still in it's
infancy so please bare with me as I try to explain my situation.

I have created a single page that with the use of many controls (i.e.
roundedcorners component [see www.4guysfromrolla.com], buttons and
panels) functions like a tab control. The buttons are
programmatically designed to make the corresponding panel visible.

Sample aspx.vb code:

Private Sub btnEvent_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnEvent.Click

pnlEvent.Visible = True
pnlHotel.Visible = False
pnlTravel.Visible = False
pnlPerDiem.Visible = False
pnlOther.Visible = False

End Sub

Private Sub btnHotel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnHotel.Click

pnlHotel.Visible = True
If chkhSpouse.Checked = True Then
pnlSpouseData.Visible = True
Else
pnlSpouseData.Visible = False
End If

If chkhCCHold.Checked = True Then
txthCCHoldAmt.Visible = True
lblhCCHoldAmt.Visible = True
Else
txthCCHoldAmt.Visible = False
lblhCCHoldAmt.Visible = False
End If
pnlTravel.Visible = False
pnlPerDiem.Visible = False
pnlOther.Visible = False
pnlEvent.Visible = False

End Sub

Private Sub btnTravel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnTravel.Click

pnlEvent.Visible = False
pnlHotel.Visible = False
pnlTravel.Visible = True
pnlPerDiem.Visible = False
pnlOther.Visible = False

End Sub

Private Sub btnPerDiem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnPerDiem.Click

pnlEvent.Visible = False
pnlHotel.Visible = False
pnlTravel.Visible = False
pnlPerDiem.Visible = True
pnlOther.Visible = False

End Sub

Private Sub btnOther_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnOther.Click

pnlEvent.Visible = False
pnlHotel.Visible = False
pnlTravel.Visible = False
pnlPerDiem.Visible = False
pnlOther.Visible = True

End Sub

On each of these panels there are buttons that link to a calendar
control (Calendar.aspx). Each button passes a textbox name to the
calendar control so that when a date is selected this value is passed
back to the corresponding text box.

Sample Button HTML Code:

<SPAN id="calBlock1"><A
href="javascript:calendar_window=window.open('//localhost/advtravel/calendar.aspx?

formname=AdminBooking.txteStartDt','calendar_windo w','width=230,height=230');calendar_window.focus() "><IMG
id="eStartDtCal" height="22" alt="Choose an event start date"
src="images/calendar.gif" align="absMiddle" border="0"></A></SPAN>

Sample Calendar.aspx HTML:

<%@ Register TagPrefix="cc1" Namespace="PrettyUI" Assembly="PrettyUI"
%>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Calendar.aspx.vb" smartnavigation="true"
Inherits="AdvTravel.Calendar" %>
<HTML>
<HEAD>
<title>Select a date</title>
<script runat="server">
Private Sub cntCalendar_SelectionChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cntCalendar.SelectionChanged
Dim strjscript As String = "<script language=""javascript"">"
strjscript = strjscript & "window.opener." &
HttpContext.Current.Request.QueryString("formname" ) & ".value = '" &
cntCalendar.SelectedDate & "';window.close();"
strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool
Bug
Literal1.Text = strjscript

End Sub
</script>
<asp:literal id="Literal1" Runat="server"></asp:literal>
<LINK href="http://localhost/AdvTravel/CSS/calendar.css"
type="text/css" rel="stylesheet">
</HEAD>
<BODY bgcolor="silver">
<form id="frmCalendar" runat="server">
<cc1:roundedcorners id="RoundedCorners1" runat="server"
Width="210px" BorderColor="Navy" BorderStyle="Solid"
BorderWidth="2px" CornerHeight="20px" CornerWidth="20px"
Height="210px" BackColor="WhiteSmoke">
<TABLE cellSpacing="0" cellPadding="0">
<TR>
<TD height="13">
<asp:dropdownlist id="drpCalMonth" Runat="Server" Width="100px"
CssClass="calTitle" OnSelectedIndexChanged="Set_Calendar"
AutoPostBack="True"></asp:dropdownlist>
<asp:dropdownlist id="drpCalYear" Runat="Server" Width="60px"
CssClass="calTitle" OnSelectedIndexChanged="Set_Calendar"
AutoPostBack="True"></asp:dropdownlist></TD>
</TR>
<TR>
<TD>
<asp:calendar id="cntCalendar" Runat="Server" Width="100%"
CssClass="calbody" ondayrender="Calendar_dayrender"
ShowTitle="True"
OnSelectionChanged="cntCalendar_SelectionChanged"
OtherMonthDayStyle-BackColor="White"
DayStyle-BackColor="LightYellow"></asp:calendar></TD>
</TR>
</TABLE>
</cc1:roundedcorners></form>
</BODY>
</HTML>

This functionality works well on the first visible panel on the page
however, soon as I click on a new "tab" to make a different panel
visible the the calendar functionality no longer works. The calendar
will pop-up but when a date is selected the calendar.aspx pop-up does
not close and does not write the value back to the corresponding text
field.

NOTE: There is a animated .gif on the page that also hangs when the
javascript fails.

I must conclude with first, an apology for the long-winded
explaination to my problem and second, a thank you in advance to
anyone willing to assist a newbie in trying to find a fix to this
problem.

Nov 18 '05 #2
I have not noticed that animated gifs stop being animated when the page is
loaded. It will set there an animate for hours.

"Peter Blum" <PL****@Blum.info> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
I know that IE stops animating a gif when it considers the page submitted.
I think that javascript continues to run until the page hits its unload
stage. So I'm not sure why javascript stops for you.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Judy | last post by:
How do I create a combobox in a custom menubar to display months like: 1 January 2 February 3 March etc and then assign the month number (1, 2, 3, etc) of the selected month to a...
0
by: Mike Pierson | last post by:
Hello all: I have a C# windows application that needs a custom calendar. I need this calendar displayed as a month view. I also need the ability to insert/manipulate images and text into each...
1
by: charliewest | last post by:
Is it possible to use the custom validation control to validate a calendar control via client-side script (in jscript)? I'm familiar with custom validation and client side script, and i am aware...
8
by: Tinus | last post by:
Hello all, I've create a custom control (UserControl) and have a custom Item Collection. The control is a custom calendar which is draw using the Graphics Rectangle etc. functions. It is drawn...
9
by: Matt Tapia | last post by:
I having a problem that receives the following error: Specified cast is not valid And I need some help. Here is what is happening: I have a form with a drop-down control that contains a list...
2
by: Marc Robitaille | last post by:
Hello, I built myself a calendar control. I want the control to be able to be validated by .NET validation controls. So I added the ValidationPropertyAttribute("Text") to my class declaration of...
4
by: rushikesh.joshi | last post by:
Hi All, I want to create custom control by using Web.UI.WebControls.Calendar, in which I want to set few days with different color. I had created two property to set the color and storing in...
0
by: Damian | last post by:
I have created a custom calendar control for use in a VS 2005 wizard, which consists of a label, a textbox and a calendar control. When I select a date on the calendar control the textbox is...
8
by: Radu | last post by:
Hi. I have an ASP control on my page: <asp:Calendar ID="calStart" ................ Etc </asp:Calendar> and I have a Custom Validator defined as <asp:CustomValidator
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.