Microsoft Dot Net Master

Microsoft Dot Net Master
Microsoft Dot Net Master
Showing posts with label ajax control toolkit. Show all posts
Showing posts with label ajax control toolkit. Show all posts

Tuesday, June 12, 2012

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>

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.

CalendarExtender Not working with Chrome

remove this line<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

add this line
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>