ASP.Net AJAX日历 - 只允许用户选择星期一 [英] ASP.Net AJAX calendar - only allow the user to select Mondays

查看:214
本文介绍了ASP.Net AJAX日历 - 只允许用户选择星期一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET AJAX压延机和一个TextBox。我想用户应该只能从日历中选择星期一,因为这是业务规则。

I have a ASP.NET AJAX Calender and a TextBox. I want the user should be able to select only Mondays from the calender as that is the business rule.

我可以通过使用常规的ASP.NET日历控件DayRender事件,但我希望使用AJAX日历控件,因为它更好的外观,方便的导航和部分回发。

I can achieve this by using regular ASP.NET calendar control using the DayRender event, however I wish to use the AJAX Calender control because of its better appearance, easy navigation and partial postback.

如何实现这一点(只选择星期一)使用ASP.NET AJAX日历?

How can I achieve this (selecting only Mondays) using ASP.NET AJAX calendar?

推荐答案

用户只能通过 alert 选择星期一以外的任何内容:

You could only workaround by alert the user if he tries to select anything else than a Monday:

<script type="text/javascript">
    function checkDate(sender,args){
       if (sender._selectedDate.getDay() != 1){
           alert("You can only select Mondays!");
           sender._selectedDate = new Date(); //set back to current date
           sender._textbox.set_Value(sender._selectedDate.format(sender._format))
       }
    }
</script>


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" 
   OnClientDateSelectionChanged="checkDate" TargetControlID="TextBox1" />

这篇关于ASP.Net AJAX日历 - 只允许用户选择星期一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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