validation for User Control

  • Thread starter Thread starter Paul Mason
  • Start date Start date
P

Paul Mason

Nah...validation controls are for amateurs. They are a complete waste of
space (literally). They're OK for required items, but they are a pain if
you want any real (programmatic) control...

You're better off handling the validation on the submit or post back
(depending on how you approach the subject)...Personally I prefer message
box's...users will actually read them coz they're annoying! Try out the
events for the controls as well...they can be quite useful.

Try :

Me.RegisterStartupScript("WARNING", "<script language=javascript>alert('" &
strWarning & "');</script>")

This will put a javacript message box into the form that will show when the
form posts back. The variable strWarning contains the text you want to
display. Works with all browsers as well.

Thus your code will look like :

if not me.ValidateControls(strError) then

Me.RegisterStartupScript("WARNING", "<script
language=javascript>alert('" & strWarning & "');</script>")

else

'Do what you need to do if it's all OK

end if

Regards...P
 
Waste of time and more control? Ever looked up and USED the custom validator?
We have made pretty advanced validators for our software, and never had to use
another approach. Along with the validator summaries, the users can't miss it if
you develop the pages with that in mind.

Mythran
 
Paul,

I couldn't disagree with you more. The validation controls give incredible
flexibility to a programmer. They validate client side if possible thus
speeding the user's experience when possible and still validate server side
since client side validation should never be trusted.

I doubt anyone would agree that writing your own client side and server side
validation routines could possibly be as easy or better than using the built
in validators.

That said the one bit of advice necessary for Vishesh wasn't given yet:
Always use:

If Page.IsValid Then
'---Process submittal here
End If

Before processing server side.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Paul,

I also forgot to mention using the validation summary object, which gives
the option to automatically display all validator messages in a javascript
alert box.

You're writing code that's already been written for you...

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Nah...validation controls are for amateurs. They are a complete waste of
space (literally). They're OK for required items, but they are a pain if
you want any real (programmatic) control...

Uhhh... the custom validator maybe?
 
Hi All,

I am having a user control consisting of few mandatory fields. How to
validate these mandatory fields on the .aspx page submission?

Thanks In Advance

Regards,
Vishesh
 
Back
Top