Visual Studio .NET - How to restrict a Calendar ?

Asked By Reena mathew
14-Jul-08 07:15 AM

How to restrict a Calendar to a range of months in asp.net 2005?

try this...  try this...

14-Jul-08 07:25 AM

Hi,

try the below code..

protected void calAvail_DayRender(object sender, DayRenderEventArgs e)

{

      if (e.Day.Date.Month == MonthNo)

      {

                e.Day.IsSelectable = false;

      }      

}

check this...  check this...

14-Jul-08 07:32 AM

Check this one which is explaining how to use calendar  in different ways..

You cab make use of ASP.NET AJAX Calendar Extender

for this...

http://www.dotnetcurry.com/ShowArticle.aspx?ID=149

solution How to restrict a Calendar  solution How to restrict a Calendar
14-Jul-08 08:48 AM

look at the following link. you have some good samples here,

http://www.personalmicrocosms.com/Pages/dotnettips.aspx?c=21&t=36

 

How to restrict a calendar  How to restrict a calendar
14-Jul-08 08:52 AM

let suppose calendar id is myCal then write the following code

on PreRender event of calendar::

protected void myCal_PreRender(object sender, EventArgs e)

{

if (myCal.VisibleDate.Year < 2004 || (myCal.VisibleDate.Year == 2004 && myCal.VisibleDate.Month <= 1))

{

myCal.PrevMonthText = "";

} else

{

myCal.PrevMonthText = "<";

}

if((myCal.VisibleDate.Year == 2008 && myCal.VisibleDate.Month >= 12)||

myCal.VisibleDate.Year > 2008

)

{

myCal.NextMonthText = "";

}

else

{

myCal.NextMonthText = ">";

}

}

restrict calendar months  restrict calendar months
14-Jul-08 09:29 AM
end of post
hi, here is sample for dates.  hi, here is sample for dates.
14-Jul-08 01:05 PM

Hope yuo can an idea of how to proceed.

protected void Page_Load(object sender, EventArgs e)
{
   Calendar1.VisibleDate = DateTime.Now;
}

protected void Calendar1_PreRender(object sender, EventArgs e)
{
    int minYear  = 2006;
    int minMonth = 1;

    int maxYear  = 2007;
    int maxMonth = 12;

    if (Calendar1.VisibleDate.Year > maxYear || (Calendar1.VisibleDate.Year == maxYear && Calendar1.VisibleDate.Month >= maxMonth))
    {
        Calendar1.NextMonthText = string.Empty;
    }
    else
    {
        Calendar1.NextMonthText = ">";
    }

    if (Calendar1.VisibleDate.Year < minYear || (Calendar1.VisibleDate.Year == minYear && Calendar1.VisibleDate.Month <= minMonth))
    {
        Calendar1.PrevMonthText = string.Empty;
    }
    else
    {
        Calendar1.PrevMonthText = "<";
    }
}

No property for range in canlender control for fix month range  No property for range in canlender control for fix month range
15-Jul-08 12:27 AM

No property for range in canlender control for fix month range, u can achive this only by customized by other property like visible , u take own logic for set visible true or false depend upon that range.

 

Create New Account