Mystery with Custom Validation and Calendar control

R

Radu

Hi. I have this elementary function:

Protected Sub ServerValidate(ByVal source As Object, ByVal args As
System.Web.UI.WebControls.ServerValidateEventArgs)

Dim objCustomValidator As CustomValidator
Dim dtChosenDate As Date

objCustomValidator = CType(source, CustomValidator)
dtChosenDate =
CType(objCustomValidator.Parent.FindControl("calStart"),
Calendar).SelectedDate

'The date must be greater than today: (for now, we'll read the date of
the computer... although we
'should probably read the date of some server):

If DateDiff(DateInterval.Day, dtChosenDate, Now) >= 0 Then
objCustomValidator.Text = "*"
objCustomValidator.ErrorMessage = "The date should be greater than
today!"
args.IsValid = False
Else
args.IsValid = True
End If

objCustomValidator = Nothing
End Sub

On the same page I have a ValidationSummary control:

<asp:ValidationSummary
ID="validSummary"
ShowSummary="False"
DisplayMode="BulletList"
HeaderText="The following data is wrong or missing:"
ShowMessageBox="true"
runat="server"/>

Somehow when I run the code, the * (the red star) is set near the
calendar -
see line
objCustomValidator.Text = "*"
but the error message, although set, is not shown by the
ValidationSummary. The ValidationSummary does its job, preventing me
to leave the page until I select a date in the future, but it does NOT
tell me anything other than making the star visible - the message box
does not even pop up. What could it be ?

PS. The exact same ValidationSummary works great for the other
controls on the form, although, true, those have the .ErrorMessage
property set at design-time.

PS. The same strategy (see code above) works just fine for other
controls, like text-boxes, on other pages, even though those controls
are in a repeater !!!

Thank you very much.
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top