locked
clicking on a date several times and have the display show always RRS feed

  • Question

  • User702049738 posted

    Dear all;

    I have the following calendar code in my porgram..However, i would like to modify the code so that if a particular date is clicked several times it will always show the date instead of having the date disappear the second time it is clicked on. All help is appreciated. Thank you.

    The link below shows you where I got the sample code from

     http://www.w3schools.com/aspnet/showasp.asp?filename=demo_prop_webcontrol_calendar_selecteddate

    however, find the actual code below.

     

    <html>
    <head>
    <script  language="VB" runat="server">
    Sub Change(obj As Object, e As EventArgs)
          Response.Write("Date: ")
          Response.Write(cal1.SelectedDate.ToShortDateString())
    End Sub
    </script>

    </head>

    <body>
    <form runat="server">
    <asp:Calendar id="cal1" runat="server" OnSelectionChanged="Change" />
    </form>
    </body>
    </html>

     

    Wednesday, January 5, 2011 3:07 PM

Answers

  • User702049738 posted

    No, that isnt what I wanted...however though I finally figured it out...My problem was basically related to the selectedchanged. onselectedchange tends to get fired only if there is a change and if there is no change in the date then it wouldnt be fired. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 7, 2011 2:44 PM

All replies

  • User-1998067147 posted

    Hi,

    You should use a asp.net label to show the selected date as shown below:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <script  language="VB" runat="server">
            Sub Change(ByVal obj As Object, ByVal e As EventArgs)
                lblDate.Text = "Date: " + cal1.SelectedDate.ToShortDateString()
            End Sub
            
            Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
                If (Page.IsPostBack) Then
                    
                End If
            End Sub
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="lblDate" runat="server" Text=""></asp:Label>
        <asp:Calendar id="cal1" runat="server" OnSelectionChanged="Change" />
        </div>
        </form>
    </body>
    </html>


    Regards,

    Ahsan Muhammad Khan

    Wednesday, January 5, 2011 4:43 PM
  • User702049738 posted

    No, that isnt what I wanted...however though I finally figured it out...My problem was basically related to the selectedchanged. onselectedchange tends to get fired only if there is a change and if there is no change in the date then it wouldnt be fired. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 7, 2011 2:44 PM