By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,315 Members | 2,150 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,315 IT Pros & Developers. It's quick & easy.

Problem with a custom calendar control

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.