It sounds like you are mixing a few things together.
First, you appear to be using the Validators the hard way. Why touch
the PreRender event? Simply use the CustomValidator instead of the
BaseValidator and implement the ServerValidate event.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidat
or.servervalidate.aspx
Then you can set the ClientValidationFunction which points to the
Javascript function which runs on the client-side.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidat
or.clientvalidationfunction.aspx
It will automatically use the values from your ErrorMessage and Text
properties.
Also, I believe what you want to do is maintain a common and shared set
of strings to be used across the application. This is done in .NET
using Resource (.resx) files.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conResourcesInResxFileFormat.asp
For the sake of simplicity, I would create a class exposing logically
named Properties which do lookups in the .resx shared file. Then you
just add new entries in your .resx file, wrap it in the helper class
and every class which sets an ErrorMessage would use it. Each
developer does not have to concern themselves with how it is loading
the string, but can easily access it.
Brennan Stehling
http://brennan.offwhite.net/blog/
> Is there a way to set/change the ErrorMessage and/or Text property of
> validationcontrols without making a trip to the server? What I have so
[quoted text clipped - 7 lines]
>
> Thanks.
jdp - 04 Oct 2006 15:32 GMT
Thanks for the reply and please forgive me newness or simplicity in
these questions...
If I understand what you're saying, coding the ServerValidate event in
accordance with the ClientValidationFunction covers the possibility of
javascript being disabled on the client machine. I'm trying to
eliminate the call to the server for validation. The reason I'm using
BaseValidator is that it gives me ControlToCompare as well as
ControlToValidate. Inheriting from CustomControl doesn't give me
ControlToCompare. I'm trying to create a validating control that can
encompass all types of validation. What I'm still missing is the piece
that modifies the ErrorMessage property dynamically. For example, if
this field is required, I want the message to display 'Required' or if
it has an invalid format, display 'Invalid format', all of which is
done withouth going to the server. If these messages change, I'd like
to have a place where they're stored so I just change the actual
message and the control will pick it up without recompiling the
control.
I'm basing my control on what was discussed here:
http://aspalliance.com/371_Creating_A_Designer_Enabled_Custom_Validator_Control_
Pt_II_Client_Side
Any feedback is appreciated.
> It sounds like you are mixing a few things together.
>
[quoted text clipped - 27 lines]
> Brennan Stehling
> http://brennan.offwhite.net/blog/
Brennan Stehling - 04 Oct 2006 16:14 GMT
Technically this is what you want to do...
http://brennan.offwhite.net/blog/2004/12/15/replacing-your-inner-html/
However, your Javascript function to test your control value and
finding the block to place your message is another issue. If you are
using a ValidationSummary control you need to insert your new text in
place of what was there.
To my knowledge there is no Javascript API to adjust the ErrorMessage
on the client-side, but that would be quite useful. I know it can be
done, but without spending some time working out the details I could
not tell you what to do.
I think your attempt to create the big daddy of all validators may be a
very difficult chore. Look at how Peter Blum does it for some ideas.
http://www.peterblum.com/VAM/Home.aspx
Brennan Stehling
http://brennan.offwhite.net/blog/
> Thanks for the reply and please forgive me newness or simplicity in
> these questions...
[quoted text clipped - 51 lines]
> > Brennan Stehling
> > http://brennan.offwhite.net/blog/
jdp - 04 Oct 2006 16:50 GMT
Thanks, I will.
> Technically this is what you want to do...
>
[quoted text clipped - 17 lines]
> Brennan Stehling
> http://brennan.offwhite.net/blog/