In this article I will explain with an example, how to implement
AJAX CalendarExtender control with
ImageButton in ASP.Net using C# and VB.Net.
Installing AjaxControlToolkit package using Nuget
HTML Markup
The HTML Markup consists of following controls:
ScriptManager – For enabling ASP.Net
AJAX.
TextBox – For capturing the user input.
Displaying ImageButton
ImageButton – For displaying calendar icon.
CalendarExtender – For displaying calendar.
The
AJAX CalendarExtender has been assigned with the following properties:
TargetControlID – The control where the Text will displayed.
PopupButtonID – The control which opens the Calendar.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="txtDate" runat="server" ReadOnly="true" />
<asp:ImageButton ID="imgPopup" runat="server" ImageUrl="~/Image/calendar.gif" />
<ajaxToolkit:CalendarExtender ID="Calendar1" runat="server" TargetControlID="txtDate" PopupButtonID="imgPopup" />
The above property can be set through Code-Behind in following way:
C#
imgPopup.ImageUrl = "~/Image/calendar.gif";
VB.Net
imgPopup.ImageUrl = "~/Image/calendar.gif"
Screenshot
Demo
Downloads