如何在ASP.NET中的ajax日历扩展程序控件中禁用过去和将来的周末日期 [英] How to disable past and future week end dates in ajax calendar extender control in ASP.NET

查看:70
本文介绍了如何在ASP.NET中的ajax日历扩展程序控件中禁用过去和将来的周末日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我确实要求在asp的ajax日历扩展器控件中禁用前一个和即将到来的周末日期[星期六和星期日]。净。我试过很多网络链接通过网络的答案,但无法得到确切的输出。如果有人知道有关我的要求的任何信息,请分享您的观点或相应的代码。



注意: - 我希望此功能仅适用于ajax日历扩展器控件而不是asp日历控件。









但是没有能够得到输出,它显示错误,如未定义的长度..

我也想禁用以前的日期..请帮我解决这个问题。

提前致谢。



我的尝试:



我尝试使用以下代码来禁用周末。

============================ ===========================

Dear all,

I do have a requirement that to disable previous and coming week end dates[saturday and sunday] with in ajax calendar extender control of asp.net. i've tried with many web links answers through net, but unable to get the exact output. if anyone knows any information regarding my requirement please share your views or corresponding code.

Note:- i want this functionality only with ajax calendar extender control not with asp calendar control.




but didn't able to get the output, and it shows an error like "length of undefined.."
and i also want to disable previous dates..please help me to solve this.
Thanks in advance.

What I have tried:

i've tried using following code to disable week ends.
=======================================================

<asp:Textbox id="txtDate" runat="server"/>
<asp:ImageButton id="Imgbtn" runat="server" imageurl="images/calendar.jpg"/>
<ajax:calendarExtender id="DisabledWeekendsCalendar"  runat="server" popupbuttonid="Imgbtn" TargetControlId="txtDate" />





我的Javascript功能: -

==================== =====





My Javascript function:-
=========================

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 == "DisabledWeekendsCalendar" + j + "_0") {
        sender._days.all[i].disabled = true;
      }

      if (sender._days.all[i].id == "DisabledWeekendsCalendar" + j + "_6") {
        sender._days.all[i].disabled = true;
      }
    }
  }
}

推荐答案

添加标题:

Add Header:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
 TagPrefix="asp" %>





标记:



Markup:

<asp:CalendarExtenderID="Calendar1"runat="server" 
    Enabled="True" TargetControlID="TextBox1"Format="dd/MM/yyyy" ></asp:CalendarExtender>





要禁用过去的日期,请在页面加载中使用以下代码:



To disable a past date use the following code in the "Page load":

protected void Page_Load(object sender, EventArgs e)
{
   Calendar1.StartDate = DateTime.Now;   //to dissable past Date
}





要禁用将来的日期,请在页面中使用以下代码load:



To disable a future date use the following code in the "Page load":

protected void Page_Load(object sender, EventArgs e)
{
   Calendar1.EndDate = DateTime.Now;   //to dissable future  Date
}


这篇关于如何在ASP.NET中的ajax日历扩展程序控件中禁用过去和将来的周末日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆