Custom webcontrol and Validators
-
Hi guys! Well, I've built a custom webcontrol and i'm having a little trouble with validation. Actually, validations works fine. (I've setup the ValidationProperty attribute). The problem is that if use a RegularExpressionValidator, for example, and I fill the field incorrectly, the postback occurs and then validation get in action. But, I want it in the client side. If i use, the same validator for a TextBox control, works fine: occurs the validation AND then if successful, postback. I don't know what I doing wrong here. I will appreciate any kind of help. PS. sorry for my poor english... =) ..:: Bocão
-
Hi guys! Well, I've built a custom webcontrol and i'm having a little trouble with validation. Actually, validations works fine. (I've setup the ValidationProperty attribute). The problem is that if use a RegularExpressionValidator, for example, and I fill the field incorrectly, the postback occurs and then validation get in action. But, I want it in the client side. If i use, the same validator for a TextBox control, works fine: occurs the validation AND then if successful, postback. I don't know what I doing wrong here. I will appreciate any kind of help. PS. sorry for my poor english... =) ..:: Bocão
If you want client side validation i.e. without being postback then write a javascript function add this function to the control you want to validate. string jscript="Javascript:fn();"; controlname.Attributes.Add("onchange",jscript); Share knowledge to enhance your learning
-
If you want client side validation i.e. without being postback then write a javascript function add this function to the control you want to validate. string jscript="Javascript:fn();"; controlname.Attributes.Add("onchange",jscript); Share knowledge to enhance your learning
But i want o use a RE validator. Do I really have to implement a javascript function to do that? And more, why with standard control works? ..:: Bocão
-
Hi guys! Well, I've built a custom webcontrol and i'm having a little trouble with validation. Actually, validations works fine. (I've setup the ValidationProperty attribute). The problem is that if use a RegularExpressionValidator, for example, and I fill the field incorrectly, the postback occurs and then validation get in action. But, I want it in the client side. If i use, the same validator for a TextBox control, works fine: occurs the validation AND then if successful, postback. I don't know what I doing wrong here. I will appreciate any kind of help. PS. sorry for my poor english... =) ..:: Bocão
Hi there, At the server side, the validator validates your custom control based on the property specified in the ValidationProperty attribute. At the client side, it relies on the
value
attribute of the element specified in the controltovalidate property of the validator. If your control renders to an element at the client side which does not support thevalue
attribute, then validation at the client side always succeeds. The reason as to the textbox can be validated at the client side is that the input text element does have thevalue
attribute, so the validator can get the value of the input text to validate. If you want to validate at the client side, you might consider using a custom validator and provide your own client side validation function. For more information, you can see the RegularExpressionValidatorEvaluateIsValid function in the WebUIValidation.js file. -
Hi there, At the server side, the validator validates your custom control based on the property specified in the ValidationProperty attribute. At the client side, it relies on the
value
attribute of the element specified in the controltovalidate property of the validator. If your control renders to an element at the client side which does not support thevalue
attribute, then validation at the client side always succeeds. The reason as to the textbox can be validated at the client side is that the input text element does have thevalue
attribute, so the validator can get the value of the input text to validate. If you want to validate at the client side, you might consider using a custom validator and provide your own client side validation function. For more information, you can see the RegularExpressionValidatorEvaluateIsValid function in the WebUIValidation.js file.Oh... Damn... Allright. I have already seen the WebUIValidation.js file, but enough i thougt. And i don't want to "hack" it. Thank you for the tips... I'm gonna try a few ideas and, if works, i come back and tell you. Have a nice day. ..:: Bocão