I have a sharepoint datetimecontrol in a webpart that i am creating
in C#, this sits alongside some other text boxes. When I save the
form i want to check that a) the user has selected a date and b) the
date is valid. Im using wss 3.0.
eg. I create the datetimecontrol as follows
_lblStartDate = new Label();
_lblBeginDate.ID = "lblBeginDate";
_lblBeginDate.CssClass = "amx-addeditmodel-fieldlabel";
_lblBeginDate.Text = WebPartsResources.amxFieldLabelBeginDate;
_dtcBeginDate = new DateTimeControl();
_dtcBeginDate.ID = "dtcBeginDate";
_dtcBeginDate.DateOnly = true;
_dtcBeginDate.IsRequiredField = true;
_dtcBeginDate.ErrorMessage = "ENTER A DATE!";
Now, being quite new to all this I thought I could add an asp
required field validator to the control and possibly a range
validator. I read somewhere you cannot do this for date controls
(however is this just the calendar control i.e. not the
datetimecontrol which is sharepoint specific). So why not try it you
say? Well i had enough problems on my page without knowing if this
was one of them!
Q1. Is this the case?
Q2) If I dont add a validator i thought I could just call validate()
when saving the form and as i set its IsRequiredField to true, and
then I did not set date it would fail and show the errormessage but
it was saying the datecontrol was valid even though there was no
date. Ive probably got the wrong end of the stick on this.
Q3_ I looked in the sdk and to be fair i found it pretty useless,
i.e. no examples in code and no description of what each property
actually meant, thus any help greatly appreciated