How to disable a specific date in the calender ?

 Posted by Vivek.Ramapuram on 5/19/2015 | Category: ASP.NET Interview questions | Views: 412 | Points: 40
Answer:

If we want to disable a specific date of the calendar control so that it is not selectable.

ASPX PAGE :
<asp:Calendar runat="server" ID="Calendar1" OnDayRender="RenderDays" /> 


CODE BEHIND :
protected void RenderDays(object sender, DayRenderEventArgs e)

{
if (e.Day.DayNumberText.Equals("25"))
{
e.Day.IsSelectable = false;
}
}

we have specified the OnDayRender event of the Calendar control that fires RenderDays sever side method. we have found out the day that needs to disable and set its IsSelectable property to false.


Asked In: While Learning | Alert Moderator 

Comments or Responses

Login to post response