How to highlight Today's Date in ASP.NET AJAX Calender Extender

Here is a simple way to highlight Today's Date in ASP.NET AJAX Calender Extender using JavaScript.

Code for .aspx page:

<asp:TextBox ID="DateTextBox" runat="server"  />
<asp:Image ID="Image1" runat="server" ImageUrl="Calendar_scheduleHS.png" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="DateTextBox" PopupButtonID="Image1" OnClientShowing="CurrentDateShowing">
</ajaxToolkit:CalendarExtender>



If you notice in the above code I am calling Javascript function "CurrentDateShowing" on the CalendarExtender which set’s Today’s Date.

Here's the Css Style sheet:
.cal_theme .ajax__calendar_active    
  
{      
    color: Red;       
    font-weight: bold;       
    background-color: #ffffff;  
}


Here's the JavaScript:
<script type="text/javascript">
function CurrentDateShowing(e) 
{
      if (!e.get_selectedDate() || !e.get_element().value)
  
      e._selectedDate = (new Date()).getDateOnly();
}     
</script>


That's it !!!!

Now try to run the page (view page in browser) - Once you click on calender image button, you would see Today’s date is highlighted.

 

About Author

Written By Lavish Kumar

Based out of New York, USA, Lavish Kumar is a full stack web developer by profession and founder of Striving Programmers, a trusted community for developers that offers a wealth of articles and forums to assist individuals with improving their software development skills.

Related Blog Posts
Leave your comment
Comments
5/18/2014 10:10 PM
thank you very much realy your article is very helpful to me
thanks again
5/18/2014 10:10 PM
thank you very much realy your article is very helpful to me
thanks again
5/18/2014 10:39 PM
You're welcome Doaa, I am glad this article was helpful to you :)
5/18/2014 10:39 PM
You're welcome Doaa, I am glad this article was helpful to you :)
10/17/2014 10:52 PM
Great. I tried the code and it worked. Thanks.
10/17/2014 10:52 PM
Great. I tried the code and it worked. Thanks.
10/17/2014 11:46 PM
Good to hear that it helped :)
10/17/2014 11:46 PM
Good to hear that it helped :)
3/30/2015 6:51 PM
thank you so much lavish your artical is nice.
3/30/2015 6:51 PM
thank you so much lavish your artical is nice.
3/30/2015 11:21 PM
You're welcome Pranav!
3/30/2015 11:21 PM
You're welcome Pranav!
4/30/2015 10:02 AM
I am using the AjaxControlToolkit CalendarExtender in my web site and its working in the visual studio 2012 but after publish to IIS Calendar Extender control won't show !
i am using AjaxControlToolkit.dll Version 4.5.7.1213
How can i fix this ?
This is the code Link : http://stackoverflow.com/questions/29938899/ajaxcontroltoolkit-calendarextender-not-working-after-publish
4/30/2015 10:02 AM
I am using the AjaxControlToolkit CalendarExtender in my web site and its working in the visual studio 2012 but after publish to IIS Calendar Extender control won't show !
i am using AjaxControlToolkit.dll Version 4.5.7.1213
How can i fix this ?
This is the code Link : http://stackoverflow.com/questions/29938899/ajaxcontroltoolkit-calendarextender-not-working-after-publish