.NET drop down calendar control

I was wondering what calendar control IQA uses when you add a date parameter to a query. The control is like a drop down list, which when clicked on brings up a calendar, so you can select a date and hence remove user error. This does not come standard with VS.NET 2003.
Where can I obtain this calendar and how is it set up in .net?

Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

iMIS custom control

That's actually a custom control that ASI developed, and is delivered as part of iMIS. (Unfortunately, right now, it's IE-only; that restriction should be removed in the future.)

Calendar Control

Okay Leo, sorry about the delay; best practices for reuse of our custom controls is something we're still working out all the details of. Right now our documentation is pretty scant, but I can give you enough to hopefully get you started.

Before I do, and for anyone else interested in reusing this control, I have to warn you that we currently do not officially support the reuse of ASI custom controls, nor do we guarantee future compatibility, so the control may change or disappear in a future iMIS release. That said, we do consider iMIS a platform, so I'm sure you'll see more solid information (and documentation) in the future.

With the caveats out of the way, the class you're looking for is Asi.Web.UI.WebControls.BusinessCalendar, and is located in the Asi.Web.dll assembly.

To use it, you would need to register the class in your .aspx or .ascx file using the following:

<%@ Register TagPrefix="asiweb" Namespace="Asi.Web.UI.WebControls" Assembly="Asi.Web" %>

Then, at the place you want the calendar control to appear, add this:

<asiweb:BusinessCalendar id="BusinessCalendar1" runat="server">

You can set various properties on the BusinessCalendar, but the one you'll most likely be interested in is Text. This value sets and retrieves the date/time the BusinessCalendar currently represents. Retrieving the text property will give you the date/time in universal format (which you can convert to a DateTime object with the line DateTime newDateTime = DateTime.ParseExact(value, "u", CultureInfo.InstalledUICulture.DateTimeFormat, DateTimeStyles.AdjustToUniversal);). Setting the text property can be done with either a universal date time string (like you would get from dateTime.ToString("u", CultureInfo.InstalledUICulture.DateTimeFormat)) or just a normal date string (which will result in a "best guess" at what the date means according to the current culture etc).

You can also databind the date control to Business Objects (anything that inherits from BusinessItem, that you got from a BusinessController) by setting the BoundBusinessItem and BoundPropertyName properties, then calling DataBind() (either directly or as a result of a page-wide or control-wide DataBind). The Value property will give you back a DateTime object (or accept a DateTime object) if the control has been databound; otherwise I would use Text instead.

Finally, the calendar requires a pair of javascript files, common.js and calendar.js. If your page is running as part of the iMIS web application, you shouldn't need to do anything; if you're using it in a different application directory, you'll need to copy those two files to /YourApp/AsiCommon/scripts/ so that the calendar can find them. Likewise, it requires some images, which are in the app server's /AsiCommon/Controls/Shared/Calendar/images/ folder (and need to be in that path if you're using a non-iMIS application directory).

Let me know if that gets you started or you have additional questions.

Didn't work the same way this time

I am working on another .NET project which is using the calendar control. I reused the same code as before, but this time when I selected a date, it would not populate the text box. I noticed a javascript error on the page.
It was pointing at line 150 of calendar.js. This line has the following code: " __doPostBack(postbackID, '');".

After scratching my head for a while, I ended up adding the autopostback=true in the .aspx file. Example:

This fixed the problem. Still have no idea why it worked in the other application without the autopostback attribute.

a little buggy

For some reason the calendar does not come up directly underneath the text box every time you click on the little calendar image. Sometimes it comes up lower on the page. Then when you click on it again, it will adjust itself and appear underneath the text box. Do you know how to fix this issue?

I could not find common.js anywhere. Are you sure this is required?

A couple of things

First off, I note in the .aspx you sent me, you're manually referencing calendar.js; you don't need to do that. The calendar control will automatically insert a reference to the .js at runtime. (This is true of common.js as well.)

Second, common.js should be in the Program Files\ASI\iMIS15\net\AsiCommon\Scripts folder, just like calendar.js. I just checked one of our test installs, and it does appear to be there.

You may need to add a reference to Menu.js (in the same folder as calendar and common); I think some of the utility functions for getting element locations are in there.

Let me know if that helps.

using iMIS10

I am actually developing this for iMIS 10.6 not iMIS15. The iMIS 10.6 "\iMIS.Net\ASICommon\scripts" folder does not contain a common.js or Menu.js. It only contains: AtomPanelExplorer.js, nav.js, System.js, calendar.js and StyleSheet.js. I also did a view source on one of the iMIS 10.6 .net pages which have the calendar control on it and the only files that are referenced are: System.js, StyleSheet.js and calendar.js.

But most importantly, removing the reference I had in my .aspx fixed that issue of the calendar appearing lower on the screen.

Thanks so much for your help.

Gotcha

Ah, I didn't realize this was 10.6; obviously I have 15 on the brain. ;)

Glad to hear that the issue is resolved and that you're finding the control useful.