/ Published in: ASP
I wanted to share this information with everyone, especially those who are at the initial level and starting their hands on ASP.NET. Disabling a range of dates on a calendar control is a great way to reduce data-entry error. For example, imagine a scheduling system for an organization whose doors are open Monday through Friday. Ideally, any calendar controls should disable Saturday and Sunday to prevent users from accidentally choosing them. This can be accomplished by taking advantage of the moneylender event of the calendar control. First, in your asp markup, wire up a method to the event.
If you think that you know some better techniques or you belong to a well reputed <a href="https://www.ingic.ae/dubai/software-development">software development companies in Dubai</a> then please share your thoughts and suggestions.
If you think that you know some better techniques or you belong to a well reputed <a href="https://www.ingic.ae/dubai/software-development">software development companies in Dubai</a> then please share your thoughts and suggestions.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<asp:Calendar Visible="false" ID="DisabledWeekendsCalendar" runat="server" ondayrender="DisabledWeekendsCalendar_DayRender"></asp:Calendar> Finally, in your .NET code, create the method which checks to see if a day is a weekend, and if so disables it. protected void DisabledWeekendsCalendar_DayRender(object sender, DayRenderEventArgs e) { if (e.Day.Date.DayOfWeek == DayOfWeek.Saturday || e.Day.Date.DayOfWeek == DayOfWeek.Sunday) { e.Day.IsSelectable = false; e.Cell.ForeColor = System.Drawing.Color.Gray; } }