[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Re: Calendar control functionality

Ken Cox [MS MVP]

2/27/2004 3:27:00 AM

Hi Victor,

This is a bit of a hack, but since every click on the calendar causes a
postback, you can use that event. You then determine whether you want to use
the value from the calendar. If so, send it on to the SelectionChanged
event. If not, forget the click.

Here's what I mean.

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If IsPostBack Then
If viewstate("stopcalendarchange") _
<> True Then
Call Calendar1_SelectionChanged _
(Calendar1, Nothing)
End If
End If
End Sub

Private Sub Calendar1_SelectionChanged _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Calendar1.SelectionChanged
Label1.Text = _
Calendar1.SelectedDate.ToLongDateString & _
" at " & Now.ToLongTimeString
End Sub

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
viewstate("stopcalendarchange") = True
Label1.Text = "Stopped getting same date."
' Calendar1.Enabled = False
' Calendar1.Visible = False
End Sub

<form id="Form1" method="post" runat="server">
<asp:Calendar id="Calendar1" runat="server"></asp:Calendar>
<P>
<asp:Label id="Label1" runat="server"></asp:Label></P>
<P>
<asp:Button id="Button1" runat="server" Text="Stop getting same
date"></asp:Button></P>
</form>

Ken
Microsoft MVP [ASP.NET]
Toronto


"Victor" <anonymous@discussions.microsoft.com> wrote in message
news:437DFF60-935C-46F3-BD6B-751BBF75DB75@microsoft.com...
> 1) I'm trying to figure out how to catch event when calendar is open and
> I'm clicking on date SelectedDate.
>
> I have a calendar on page which visible only when user presses select_date
> button. When user selects date, calendar control's Visible property set to
> false and I'm writing selected date into label.
> As you know when you click on SelectedDate nothing happens but at this
> point I want for calendar to behave the same way as it would when date
> selected changed.
>
> 2) Also, how can I close calendar when user doesn't clicks on a calendar
> but somewhere else on the page?
>
> Thanks,
> Victor