开发者

ASP.Net AJAX calendar - only allow the user to select Mondays

开发者 https://www.devze.com 2023-03-16 14:55 出处:网络
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.

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.

I can achieve t开发者_如何学Pythonhis 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.

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


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" />
0

精彩评论

暂无评论...
验证码 换一张
取 消