Bind drop down list to calendar with conditions - c#

I'm new to ASP.NET and C# and I'm having trouble completing a project. I'm trying to create a page where a user can select an item from a drop-down list, which contains four options. Each option is tied to specific days and times of the week. I'm trying to make it so when a user selects an option where the specified days are Monday, Wednesday, and Friday, it makes it so the corresponding calendar only allows for Monday, Wednesday, or Friday to be selected.

No way ofdoing this the way you want to. Check out some javascript calendar pickers that can be configured to only allow certain months and use that on front end.

Perhaps you can store the current selection and then in the on select event if the event is one you don't want the user to select then reselect the stored (previous) selection?

Related

How to restrict text entry on Kendo Angular Date Picker?

Kendo's Angular Date Picker, restricts the date selection using [min] and [max] to select date from the UI. However, for text entry (user types in the date instead of selecting from the datepicker) user is restricted to enter months above 12 and dates above 30/31 accordingly. But, I need to restict user to type the year as well. Suppose if user types 1996 and my max year is 1995, the date year should change to 1995.
You can make one function which triggers when date is changed, this function should check if your requirements are satisfied with newly entered date OR it should revert back to last value . The Benefit of this approach is that user still can type the values but still it should be inside your validation range.

C# selected calendar days into datagridview columns

I'm creating this function for my attendance monitoring system, now I want to have a datagridview (or if you can suggest some other way) that will show the school days based on the calendar (with out sat. and sun.)
Similar to this, the highlighted part:
As columns and it will change depending on the filter that I select in my combobox.
e.g. I selected January and only the school days of January will be the header.
I just have these 2 questions:
1. How can I make the selected days (of month selected in combobox) to headers of column.
2. what will be my datasource? should I create a database for it?
Help me out, I can't quite get the logic needed here.

easily change month and year in calendar in asp.net

I want to use calendar to select a date, but it takes time when I have to pick another month or year, because I can only pick another month by clicking prev or next month one by one, is there any other way to make it easier to select a month or a year? maybe something like dropdownist
Most people use a javascript library for a responsive calendar control allowing you to quickly select a month/year.
Two possibilities include:
Microsoft's Ajax Control Toolkit. Note that in the sample you can click the Month/Year header to quickly select a different month or year.
or
jQuery Datepicker with Month/Year dropdowns.
If you're looking at a dropdownlist, you have to build it yourself. Do take note of the Leap Year algorithm.

Generate dynamic calendar controls

How to generate dynamic controls based on selecton by user?
I had appeared for one practical test recently where they had the below mentioned requirements
They had 2 calendars (asp.net default).
They had two options (radio button list) : One was "Repeat On" and another "Repeated On"
The Repeat on had 2 drop down :
1) Day Dropdown: It values were: Every, Every Other Day, Every Third Day
2) Duration dropdown: It values were: Day, Month, Week, Year
The Repeated on had 2 drop down :
1) Week: the values were First Week, Second Week, Third Week
2) Day: Sunday, Monday .... Saturday
Now when i click the first calendar's date as say August 10 2010 and second one as January 26 2011, then i wanted that dynamic calendars should be generated that would show the Calendars from August to January (inclusive of both)
For Filter purpose, if i select First Sunday (From REPEATED ON Option) then first sunday of dynamic calendars should be selected. If i select every third day then every 3rd day should be selected (in dynamic generated calendars)
What i did was : Could generate dynamic calendars by creating object of calendar class.. is that right? Plus i searched on google and they show that DayRender Event could be a possible solution but that didn't help...
How to do that? How to generate dynamic calendar?
Please let me know if question is not being understood.
Pass me on code similar to that the least
thanks!
Sounds like what you want to do is set the properties Calendar.SelectedDate and Calendar.VisibleDate.
I'm not sure exactly what you're going for since I don't know what type of control the user will be selecting your Jan 1/Jun 1 dates from, or what the 3rd sunday has to do with that. Is there only one calendar? Please explain a little more if the info below doesn't help you.
I'll paste some VB code from one of my apps, hopefully it will help you out.
Protected Sub calArrival_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles calArrival.SelectionChanged
SetFormDepartureEntry()
lblArrivalDate.Text = calArrival.SelectedDate.ToLongDateString
calDeparture.SelectedDate = calArrival.SelectedDate
calDeparture.VisibleDate = calArrival.SelectedDate
dtSelectedArrival = "1/1/2000"
'Determine if we need to see 2 months to view all possible departure dates.
If (DatePart(DateInterval.Month, calDeparture.SelectedDate) <> _
DatePart(DateInterval.Month, DateAdd(DateInterval.Day, 14, calDeparture.SelectedDate))) Then
calDeparture2.Visible = True
calDeparture2.SelectedDate = Nothing
calDeparture2.VisibleDate = DateAdd(DateInterval.Month, 1, calDeparture.SelectedDate)
Else
calDeparture2.Visible = False
End If
End Sub
OK now that you have posted the details this becomes a different question. You don't know how many calendars you need to so you will probably want to create them in code. I would suggest using a Panel control in your markup to contain all the possible result calendars. Then as you suggested earlier, create new Calendar objects as needed and add them to the "anchor" Panel's Controls collection.
Calendar objCal = new Calendar();
pnlResultsContainer.Controls.Add(objCal);
As far as setting selected days, you can only have one "selected" day per calendar I believe. However you can set the rendering styles, and whether the day is enabled, etc., by handling the Calendar.DayRender event. Maybe someone can help me out on setting up a handler for dynamically created controls in C#? I think it's something like:
objCal.DayRender += AddressOf(DynamicDayRenderHandler());
Please correct if this is not right.
Determining the correct day to set styles on in the handler will be a matter of coding against the DayRenderEventArgs.Day object which is a parameter of the event. I don't know offhand how to find the specific days/intervals you are looking for but it should be possible with a little research in the following articles:
How to: Customize Individual Days in a Calendar Web Server Control
DayRenderEventArgs.Day Property
Hope this helps.

How do I save selected dates to database from jQuery calendar

My goal here is to store a list of dates selected in a calandar to a database. The problem with most calendar controls that exist, for asp.net, is I can't get the date that was unselected with multiselect enabled. I can get a list but that is really it. I have decided not to use these because of this.
If I wanted to create my own event using the jQuery calendar below how would I go about doing this? The event would capture the day clicked, if it was unselected or selected, etc. I would use this to add/remove the dates from a collection. It is almost like how the other calendars work except for the remove part. The dates removed would be in it's own list so I know what dates to remove from the database once 'save' is clicked. I hope this is enough information.
http://www.eyecon.ro/datepicker/#about
Using Visual Studio 2005/.NET 2.0. c#
if you wanted to save multiple dates (list), you could:
-use jquery to create 1 input box for selecting date and another list area the selected dates
-on post back, have the server code check the list area for all the selected dates
if you wanted to save only one date, you could:
-use jquery to create 1 input box for selecting date
-on post back, the server code check for the that input box
hope that helps.

Categories