Problem with a Calendar control

Discussion in 'ASP .Net' started by maxrawson, Oct 15, 2004.

  1. maxrawson

    maxrawson Guest

    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_window','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.
     
    maxrawson, Oct 15, 2004
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.