Search code examples
asp.netvb.netajaxcontroltoolkit

ASP Ajax control toolkit - on date selected


I've got a calendar control on a text box I'm just wondering how I can trigger a sub when a date is chosen on the calendar?

There is a OnClientDateSelection changed in the extenders properties but im not sure how to use this.

Any help most appreciated! -- Jonesy


Solution

  • You will need to manually post back your form with some client side javascript. Then you could just check the selected date to do what you want.

        <cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDate" PopupButtonID="myButton" runat="server" OnClientDateSelectionChanged="dateChanged"></cc1:CalendarExtender>
    
        function dateChanged() {
           document.forms[0].submit();
        }
    
    Protected Sub Page_Load(ByVal sender As Object, ByVal e as EventArgs)
       If txtDate.Text <> String.Empty Then DoSomething
    End Sub
    
    Private Sub DoSomething()
      'do your work
    End Sub