我想知道是否有一个简单的解决方案可以禁用asp.net中calendarextender的周末。
我看到了这个:
first link
second link
但它没有帮助我:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="TextBox1" OnClientShown="DisableWeekends" runat="server">
</asp:CalendarExtender>
<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>
任何提示?
答案 0 :(得分:0)
将您的javascript更改为
<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 == "CalendarExtender1_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 == "CalendarExtender1_day_"+j+"_6")
{
sender._days.all[i].disabled = true;
sender._days.all[i].innerHTML = "<div>" +sender._days.all[i].innerText+ "</div>";
}
}
}
}
您的日历内容的ID是CalendarExtender1
,但在您的javascript中,您使用calendarValidToDate
喜欢示例代码!我认为这是重点
祝你好运:)