Hi nauna,
It is not possible to disable weekends from page behind.
You need to use CSS or JavaScript OnClientShown event for this.
Refer below example.
Using CSS
HTML
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.DisableWeekends .ajax__calendar_days table tbody tr td:first-child {
text-decoration: line-through;
color: red;
pointer-events: none;
cursor: default;
}
.DisableWeekends .ajax__calendar_days table tbody tr td:last-child {
text-decoration: line-through;
color: red;
pointer-events: none;
cursor: default;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc1:ToolkitScriptManager>
<asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
<asp:ImageButton ID="imgPopup" ImageUrl="images/calendar.png" ImageAlign="Bottom" runat="server" />
<cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="txtDate"
Format="dd/MM/yyyy" CssClass="DisableWeekends">
</cc1:CalendarExtender>
</form>
</body>
</html>
Using JavaScript
HTML
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
function DisableWeekends(sender, args) {
for (var i = 0; i < 6; i++) {
var row = sender._days.children[0].childNodes[1].children[i];
for (var j = 0; j < 7; j++) {
var cell = row.children[j].firstChild;
if (cell.id == sender._id + "_day_" + i + "_" + "0" || cell.id == sender._id + "_day_" + i + "_" + "6") {
cell.style.textDecoration = "line-through";
cell.style.color = "red";
cell.style.cursor = "default";
cell.style.pointerEvents = "none";
}
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></cc1:ToolkitScriptManager>
<asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
<asp:ImageButton ID="imgPopup" ImageUrl="images/calendar.png" ImageAlign="Bottom" runat="server" />
<cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="txtDate"
Format="dd/MM/yyyy" OnClientShown="DisableWeekends">
</cc1:CalendarExtender>
</form>
</body>
</html>
Screenshot