Click here to Skip to main content
12,395,252 members (65,213 online)
Rate this:
 
Please Sign up or sign in to vote.
How to hide weekends (Sat, Sun) in ajax calender?
Posted 21-Dec-12 6:48am
Updated 21-Dec-12 6:49am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (e.Day.IsWeekend)
            e.Cell.Controls.Clear();
    }

and may b this is exact u looking for--
http://stackoverflow.com/questions/554111/how-can-i-hide-weekends-when-using-the-asp-net-calendar-control[^]
  Permalink  
v2
Comments
JawadHafiz 21-Dec-12 13:31pm
   
I want for AJAX Calenderextender.
Surendra0x2 21-Dec-12 13:38pm
   
refer this link-
http://irfanyar.wordpress.com/2010/10/19/disable-weekends-for-ajaxtoolkit-calendar-extender/
and

http://net-ajax.itags.org/q_dotnet-ajax_18772.html
JawadHafiz 22-Dec-12 7:40am
   
I have already tried that, but its not working

My code
See my code

<script type="text/javascript">

function DisableWeekends(sender, args) {

for (var i = 0; i < sender._days.all.length; i++) {

for (var j = 0; j < 6; j++) {

if (sender._days.all[i].id == "calendarValidToDate_day_" + j + "_0") {

sender._days.all[i].disabled = true;

sender._days.all[i].innerHTML = "<div>" + sender._days.all[i].innerText + "</div>";

}

if (sender._days.all[i].id == "calendarValidToDate_day_" + j + "_6") {

sender._days.all[i].disabled = true;

sender._days.all[i].innerHTML = "<div>" + sender._days.all[i].innerText + "</div>";

}

}

}

}

</script

<asp:textbox id="txtcomplete" runat="server" width="100%" xmlns:asp="#unknown" />
<asp:calendarextender targetcontrolid="txtcomplete" id="CalendarExtender1" runat="server" onclientshown="DisableWeekends" xmlns:asp="#unknown">


></script>
Surendra0x2 22-Dec-12 11:01am
   
Hi,

I suggest you do that in OnClientDateSelectionChanged event. And you could use the js like below:

function checkDate(sender, args) {
if ($find("CalendarExtender1")._selectedDate == null || sender._selectedDate < $find("CalendarExtender1")._selectedDate) {
alert("Please select again!");
sender._selectedDate = new Date();
// set the date back to the current date
sender._textbox.set_Value(sender._selectedDate.format(sender._format))
}
}
Surendra0x2 22-Dec-12 11:08am
   
http://www.dotnetcurry.com/ShowArticle.aspx?ID=149
http://www.dotnetfunda.com/articles/article1001-ajax-calendarextender.aspx
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Comments
Rajesh Mahankali 3-Sep-13 2:43am
   
Hi,
I tried above javascript code but its not working in mozilla and chrome browsers, its good in IE.
I got the error in mozilla, as sender._days.all return as undefined, Can you please sujjest any alternative for this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100