The calendar control is the most used control for business applications. There is no way to avoid this. If you are using an environment where there isn't such a control, you have to buy it from outside developers or spend your time implementing it yourself. The article describes the usage of a calendar control inside a static HTML page. I faced needs to use a calendar control when I had a chance to program in ASP. I hope you found this useful.
Using the calendar control
The calendar is implemented as a standalone ASP.NET application. So any outside application in IIS can use this functionality. It's implemented as a modal window.
calendarModal.htm contains an IFrame that nests an ASP.NET
Calendar control. It was necessary to do this because of the behaivor of the IE Modal window. You can not nest form inside a modal window. I mean, actually, you can do this, but it makes a post into a new window and the "
target" attribute in the
form tag is ignored. So you can not specify a "_self" target there as it's ignored.
var result = uxCalendarFrame.document.getElementById("uxResult").innerText;
var callbackHandler = window.dialogArguments;
<body style="margin:0px;" >
frameborder="0" width="100%" height="100%"
This IFrame contains an
OnLoad event to call the callback function passed into the modal window and to cause closing of the window in case of a date selection. We pass a callback function as
uxStartDate.value = date;
uxEndDate.value = date;
<input id="uxStartDate" />
<input id="uxEndDate" />
As you can see, each date input has its own callback handler.
The server side
The calendar page contains only one event handler to indicate that data selection happens. The default value of
uxResult is "Not Set".
protected void uxCalendar_SelectionChanged(object sender, EventArgs e)
uxResult.Text = uxCalendar.SelectedDate.ToShortDateString();
The value is also used as a flag that causes not to close the calendar. Once you have selected the date, the modal window is closed.