Fixing the field defaulting when not required and no date selected

Mar 30, 2010 at 9:08 PM
Edited Mar 30, 2010 at 9:24 PM

In looking at the DateTimeByMinuteFieldControl class code, I'm wondering what will happen if the Value property's get method returned null. I'm hoping that this would correct the defaulting behavior. The get method could be modified to return null when TheDatePicker.IsDateEmpty is true and TheDatePicker.IsRequiredField is false.

P.S. I'd try it and test it, but my installation of Visual Studio cannot open the project file.

Mar 31, 2010 at 2:39 PM

FYI... I got around the project type error. It was due to a Subversion plugin. I simply edited the csproj file and removed "{593B0543-81F6-4436-BA1E-4747859CAAE2};" from the <ProjectTypeGuids>. Going to play with my null idea and post back the results later.

Mar 31, 2010 at 2:55 PM

OMG! It worked! I'm new to the CodePlex thing, so I'm not sure what to do next. Basically, all I did was exactly what I described above:

                if (TheDatePicker.IsDateEmpty && !TheDatePicker.IsRequiredField)
                   return null;

I'll do a little reading on the CodePlex policies and either post a patch or fresh code or whatever.


Mar 31, 2010 at 3:32 PM

There's another bug in the set method. Getting the AM/PM by parsing the value was returning the seconds element. I fixed it by keying on the LastIndexOf(':'). (I also cleaned up parsing the hour).


                string fieldValue = value.ToString();

                //string currentHH = fieldValue.Substring(fieldValue.IndexOf(' ') +1, ( fieldValue.IndexOf(':') - ( fieldValue.IndexOf(' ') + 1 ) ) );
                string currentHH = fieldValue.Substring(fieldValue.IndexOf(':') - 2, 2).Trim();
                string currentMM = fieldValue.Substring(fieldValue.IndexOf(':') + 1, 2);
                string currentM = fieldValue.Substring(fieldValue.LastIndexOf(':') + 4, 2);
                DropDownHH.Text = currentHH + " " + currentM;
Still haven't looked into fixing the project itself. I'm watching this discussion so post any tips for me here!
Mar 31, 2010 at 3:41 PM

Ok, so I posted the modified DateTimeByMinute.FieldControl.cs as a Patch. That was easy. :)


Apr 6, 2010 at 2:55 PM

Hey there, gcliff-

Just back from vacation; I'll test your patch and merge it in as soon as I can.