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
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