This project is read-only.

DateInputBox with empty string is NOT null | how to allow end users to 'leave it blank'

Mar 7, 2008 at 12:48 AM
Edited Mar 7, 2008 at 12:50 AM
I would like to make DateInputBox.Text=="" cause DateInputBox.IsNull to be true, but it appears the NHSCUI is designed to now allow this.

I have a DateInputBox and TimeInputBox inside a custom webcontrol (CompositeControl) and would like the end user to be able to delete all text in the DateInputBox to cause the datetime to be interpreted as null.

When I test my composite DateTimeEntry control, without entering data, the dd-MM-yyyy mask still showing, innerDateInputBox.IsNull evaluates to false, which I wouldn't expect, and the innerDateInputBox.Value is today's date, rather than null.

Tried setting innerDateInputBox.NullStrings to a new array containing just "" after creating the innerDateInputBox, but an exception is raised because "" is not an allowable null string.

Why this design decision? What should users of the webcontrols do to allow users to "leave it blank" in a simple and intuitive manner?
May 1, 2008 at 3:15 PM
this.DateInputBox1.Text = "";
Debug.Assert(this.DateInputBox1.Value.IsNull == true, "this.DateInputBox1.Value.IsNull != true");

I ran the above code in the codebehind for the page, and the assert confirms that the value is indeed null.

-Stuart.