By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,101 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,101 IT Pros & Developers. It's quick & easy.

validation for User Control

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

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

"Ibrahim Shameeque" <Ib**************@discussions.microsoft.com> wrote in
message news:1A**********************************@microsof t.com...
Use the validation controls such as requiredfield validator or custom validator etc --
Ibrahim

"vishesh vyas" wrote:
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

Nov 18 '05 #2

P: n/a
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 Mason" <ma****@cancer.bham.ac.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...

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

"Ibrahim Shameeque" <Ib**************@discussions.microsoft.com> wrote in
message news:1A**********************************@microsof t.com...
Use the validation controls such as requiredfield validator or custom

validator etc
--
Ibrahim

"vishesh vyas" wrote:
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


Nov 18 '05 #3

P: n/a
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 Mason" <ma****@cancer.bham.ac.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...

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

"Ibrahim Shameeque" <Ib**************@discussions.microsoft.com> wrote in
message news:1A**********************************@microsof t.com...
Use the validation controls such as requiredfield validator or custom

validator etc
--
Ibrahim

"vishesh vyas" wrote:
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


Nov 18 '05 #4

P: n/a
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
"Paul Mason" <ma****@cancer.bham.ac.uk> wrote in message
news:Oz**************@TK2MSFTNGP11.phx.gbl...

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

"Ibrahim Shameeque" <Ib**************@discussions.microsoft.com> wrote in
message news:1A**********************************@microsof t.com...
Use the validation controls such as requiredfield validator or custom

validator etc
--
Ibrahim

"vishesh vyas" wrote:
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


Nov 18 '05 #5

P: n/a
"Paul Mason" <ma****@cancer.bham.ac.uk> wrote in news:OzUlSQZaEHA.2812
@TK2MSFTNGP11.phx.gbl:
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?

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.