Reputation: 17
How to have a event when date is selected from Calendar Extender and it does a function in aspx.cs
Filter by Date:<asp:TextBox ID="txtDatePicker" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy"
Enabled="True" TargetControlID="txtDatePicker" />
Upvotes: 0
Views: 1637
Reputation: 21416
If you want to execute a JavaScript function when a date is selected then subscribe to onchange
event of the textbox attached to CalendarExtender. This is an event on client-side and not server-side.
You can use the snippet below to call a function doSomething()
when a date is selected. Note the onchange
attribute I have added to markup for textbox.
Filter by Date:<asp:TextBox ID="txtDatePicker" runat="server" onchange="doSomething()"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy"
Enabled="True" TargetControlID="txtDatePicker" />
<script type="text/javascript">
function doSomething() {
var x = 100;
alert(x);
}
</script>
Upvotes: 1