F
Frank Bishop
I have a user control that will open and close the calendar control when
the user clicks on an anchor tag. Instead of having the user remember to
close the calendar after they make a day selection, I would like the
calendar to close itself after the day selection. I'm using the day
selected to feed a text box (code not shown here). Here is my user
control code and HTML - Help appreciated - Frank:
<code>
' User Control Code......
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents divCalendar1 As
System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents anchor1 As
System.Web.UI.HtmlControls.HtmlAnchor
Event ctlCalendar_SelectionChanged()
Private Sub anchor1_ServerClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles anchor1.ServerClick
If divCalendar1.Style.Item("DISPLAY") = "" Then
divCalendar1.Style.Item("DISPLAY") = "none"
Else
divCalendar1.Style.Item("DISPLAY") = ""
End If
End Sub
Property ctlCalendar_SelectedDate() As Date
Get
Return Calendar1.SelectedDate
End Get
Set(ByVal Value As Date)
Calendar1.SelectedDate = Value
End Set
End Property
Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles calendar1.SelectionChanged
RaiseEvent ctlCalendar_SelectionChanged()
End Sub
'-----------------------------------------------------------------------
---------
'User Control HTML...
%@ Control Language="vb" AutoEventWireup="false"
Codebehind="ctlCalendar.ascx.vb"
Inherits="LoginWithSessionVariables.ctlCalendar" %>
<A id="anchor1" runat="server"><FONT color="#000099" size="2">calendar
open/close</FONT></A>
<BR>
<DIV id="divCalendar1" runat="server" style="DISPLAY: none; VISIBILITY:
visible; OVERFLOW: visible; POSITION: absolute; TOP: 50px">
<asp:Calendar id="Calendar1" runat="server" BorderWidth="1px"
BackColor="White" ForeColor="Black"
BorderColor="White">
<TodayDayStyle BackColor="#CCCCCC"></TodayDayStyle>
<NextPrevStyle Font-Size="8pt" Font-Bold="True" ForeColor="#333333"
VerticalAlign="Bottom"></NextPrevStyle>
<DayHeaderStyle Font-Size="8pt" Font-Bold="True"></DayHeaderStyle>
<SelectedDayStyle ForeColor="White"
BackColor="#333399"></SelectedDayStyle>
<TitleStyle Font-Size="X-Small" BorderWidth="4px" ForeColor="#333399"
BorderColor="Black" BackColor="White"></TitleStyle>
<OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
</asp:Calendar>
</DIV>
</code>
the user clicks on an anchor tag. Instead of having the user remember to
close the calendar after they make a day selection, I would like the
calendar to close itself after the day selection. I'm using the day
selected to feed a text box (code not shown here). Here is my user
control code and HTML - Help appreciated - Frank:
<code>
' User Control Code......
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents divCalendar1 As
System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents anchor1 As
System.Web.UI.HtmlControls.HtmlAnchor
Event ctlCalendar_SelectionChanged()
Private Sub anchor1_ServerClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles anchor1.ServerClick
If divCalendar1.Style.Item("DISPLAY") = "" Then
divCalendar1.Style.Item("DISPLAY") = "none"
Else
divCalendar1.Style.Item("DISPLAY") = ""
End If
End Sub
Property ctlCalendar_SelectedDate() As Date
Get
Return Calendar1.SelectedDate
End Get
Set(ByVal Value As Date)
Calendar1.SelectedDate = Value
End Set
End Property
Private Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles calendar1.SelectionChanged
RaiseEvent ctlCalendar_SelectionChanged()
End Sub
'-----------------------------------------------------------------------
---------
'User Control HTML...
%@ Control Language="vb" AutoEventWireup="false"
Codebehind="ctlCalendar.ascx.vb"
Inherits="LoginWithSessionVariables.ctlCalendar" %>
<A id="anchor1" runat="server"><FONT color="#000099" size="2">calendar
open/close</FONT></A>
<BR>
<DIV id="divCalendar1" runat="server" style="DISPLAY: none; VISIBILITY:
visible; OVERFLOW: visible; POSITION: absolute; TOP: 50px">
<asp:Calendar id="Calendar1" runat="server" BorderWidth="1px"
BackColor="White" ForeColor="Black"
BorderColor="White">
<TodayDayStyle BackColor="#CCCCCC"></TodayDayStyle>
<NextPrevStyle Font-Size="8pt" Font-Bold="True" ForeColor="#333333"
VerticalAlign="Bottom"></NextPrevStyle>
<DayHeaderStyle Font-Size="8pt" Font-Bold="True"></DayHeaderStyle>
<SelectedDayStyle ForeColor="White"
BackColor="#333399"></SelectedDayStyle>
<TitleStyle Font-Size="X-Small" BorderWidth="4px" ForeColor="#333399"
BorderColor="Black" BackColor="White"></TitleStyle>
<OtherMonthDayStyle ForeColor="#999999"></OtherMonthDayStyle>
</asp:Calendar>
</DIV>
</code>