Custom validator
-
Hi guys, I have a small problem, hope u would help me ! I'm tryin to use a custom validator on a Textbox ! Look : * The code behind now protected void first_CV_ServerValidate(object source, ServerValidateEventArgs args) { if (TextBox2.Text == "") { args.IsValid = false; } else { args.IsValid = true; } } Basically, I hoped to see a message when the Textbox is empty! But nothin happen when Click on my submit button Please help me
-
Hi guys, I have a small problem, hope u would help me ! I'm tryin to use a custom validator on a Textbox ! Look : * The code behind now protected void first_CV_ServerValidate(object source, ServerValidateEventArgs args) { if (TextBox2.Text == "") { args.IsValid = false; } else { args.IsValid = true; } } Basically, I hoped to see a message when the Textbox is empty! But nothin happen when Click on my submit button Please help me
You either need to replace the
CustomValidator
with aRequiredFieldValidator
(if you don't need any other custom logic) or set theValidateEmptyText
property of theCustomValidator
to true, to force the validator to operate on empty strings. By default, theCustomValidator
won't validate if the control is empty.Adam Maras | Software Developer Microsoft Certified Professional Developer
-
You either need to replace the
CustomValidator
with aRequiredFieldValidator
(if you don't need any other custom logic) or set theValidateEmptyText
property of theCustomValidator
to true, to force the validator to operate on empty strings. By default, theCustomValidator
won't validate if the control is empty.Adam Maras | Software Developer Microsoft Certified Professional Developer
I can't use a
RequiredFieldValidator
A custom validor is necessary. By setting theValidateEmptyText
I thing quite good. But In the same Page I haveRequiredFieldValidator
RegularFieldValidator
andValidationSummary
and others controls. When I click on the submit button I have a messageBox telling me I forgot sum requiredFields or anytthing like dat. But no reference about the field concerned by the Custom Validator in this same MessageBox! So now I am asking can I show in a messageBox the message error of my CustomValidator ? thx (sorry for my english, I'm French)modified on Friday, August 28, 2009 9:45 AM