How do we disable the dates of other months in ASP.NET ?

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

If we want to disable the dates of other month so that those dates are not selectable .

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


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

{
if (e.Day.IsOtherMonth)
{
e.Day.IsSelectable = false;
}
}


the RenderDays method that fires in OnDayRender event, we can check for the IsOtherMonth property of the day and if it is true we can set IsSelectable to false that disables the other month dates.


Asked In: While Learning | Alert Moderator 

Comments or Responses

Login to post response