Get the same selected date from the calendar two consecutive times

Discussion in 'ASP .Net Web Controls' started by mg, Jun 1, 2004.

  1. mg

    mg Guest

    When I click any date in System.Web.UI.WebControls.Calendar (C# WebForm), the SelectionChanged event handler fires. If I next click on the same date again, this event handler does not fire, so I can't get the selected date directly from the calendar on two successive attempts.

    How can I get this same selected date from the calendar on two successive attempts. Storing the value obtained on the first attempt isn't helpful
    mg, Jun 1, 2004
    #1
    1. Advertising

  2. This might be a hack but it seems to work... call SelectionChanged
    yourself....

    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]

    "mg" <> wrote in message
    news:...
    >
    > When I click any date in System.Web.UI.WebControls.Calendar (C# WebForm),
    > the SelectionChanged event handler fires. If I next click on the same date
    > again, this event handler does not fire, so I can't get the selected date
    > directly from the calendar on two successive attempts.
    >
    > How can I get this same selected date from the calendar on two successive
    > attempts. Storing the value obtained on the first attempt isn't helpful
    Ken Cox [Microsoft MVP], Jun 2, 2004
    #2
    1. Advertising

  3. mg

    mg Guest

    Thanks

    Any chance of getting the C# version of this code?
    mg, Jun 2, 2004
    #3
  4. Your best bet would be to compile it and then decompile it to C# with
    Reflector:

    http://www.aisto.com/roeder/dotnet/

    Ken


    "mg" <> wrote in message
    news:...
    > Thanks!
    >
    > Any chance of getting the C# version of this code?
    Ken Cox [Microsoft MVP], Jun 2, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    1
    Views:
    394
    Gerald Klein
    Jan 24, 2004
  2. =?Utf-8?B?bWc=?=
    Replies:
    2
    Views:
    2,057
    =?Utf-8?B?bWc=?=
    Jun 2, 2004
  3. Andy Fish
    Replies:
    3
    Views:
    344
    Tor Iver Wilhelmsen
    Nov 20, 2003
  4. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,229
    Michael Borgwardt
    May 30, 2004
  5. Rick Lubanovic

    How to dismiss Calendar Control when same date is selected

    Rick Lubanovic, Oct 20, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    138
    Rick Lubanovic
    Oct 20, 2003
Loading...

Share This Page