Calendar Bolded Dates - c#

I have a button in every row of my DataGridView. When that button is clicked, a calender should be displayed in which the selected dates (I have in list) should be bolded. The dates will be different for different buttons and so the bolded dates should also be changed for every button click. Is it possible to have a tag for every bolded date?
Is the single calender is sufficient or should I declare number of month calenders for every button.
I am very new to C#, please reply me the answer.

You can reuse the same Calendar control by specifying different BoldedDates.
DateTime[] myDates = {myDate1, myDate2};
calendar.BoldedDates = myDates;
Look at here and here for more details about bold dates.

Related

How to select the "selected Date" in asp:Calendar?

The question sounds illogical, but it is not:
I have 2 dates "Target" and "Actual". Usually the "Actual" date is very close to "Target", but not necessarily to the current date. To avoid the multiple clicks in the calendar that would navigate you to the month/year of interest, I set the selected date to my "Target" date when it is opened. This works great, BUT does not allow me to select that day, with the calendar closing automatically after selecting.
Any idea to solve this or any known alternative?
If you have a Calendar1 component, you can use a code like:
DateTime tomorrow = DateTime.Today.AddDays(1);
Calendar1.TodaysDate = tomorrow;
Calendar1.SelectedDate = Calendar1.TodaysDate;
When this calendar changed SelectionChanged the selected date, you can set the other calendar.
Tell me if you need more detail.

Bind drop down list to calendar with conditions

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?

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.

Configuring the Date Popup on the WPF DatePicker Control

I have a date picker control that I use for a data collection application. It is using MvvM data binding. When going through a list of dates (see fig1) it will populate the date picker correctly. Whenever I hit new, the date pickers are nulled out. When I pull up the popup, it selects the month and year from the previous date that was set to. (fig 2) Is there anyway to default the pop up show the current month in the current year?
Note : I would like to keep the selected date to null on a new entry to force some validation.
Fig 1
Fig 2
The following image is to show what happens when I set the DisplayDateStart.
(original answer was horribly wrong, sorry about that)
Okay, lets try this again.
Have you tried setting the fallback to today's date?
SelectedDate="{Binding TehDate, FallbackValue={x:Static sys:DateTime.Now}}"

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