|
-
Feb 18th, 2003, 12:01 PM
#1
Thread Starter
Lively Member
Validation Help..
I have a problem, it is I need to validate a Textbox so that it accepts only the numeric value. In ASP I had used client validation for that. In .NET please help me to achive the same.
Also let me know both the ways to achive this i.e., from client side as well as from server side and also the prons and cons if possible...Thanks for all the help...in advance...
Sonia
-
Feb 18th, 2003, 02:28 PM
#2
Frenzied Member
Ok, this is very easy in .NET.
Place a text box on the form. Beside the textbox, place a compareValidator control and set these properties.
Display - Dynamic
ErrorMessage - "Error message you want to show user"
ControlToValidate - TextBox1
Operator - DataTypeCheck
Type - Integer
Each time the page is posted back to the server, the validator will check to make sure that only numbers are in the textbox.
Hope that helps
Dont gain the world and lose your soul
-
Feb 18th, 2003, 03:22 PM
#3
Thread Starter
Lively Member
Dev,
Well that is good way to do. But now i think I should not allow the user to type wrong data in the first place. So how i can do it from the client side. I presume it is of no use to put code at the Server.
Sonia
-
Feb 18th, 2003, 07:34 PM
#4
Frenzied Member
Sorry, I'm not too advance when it comes to client side scripting. I just decided to learn web programming.
Dont gain the world and lose your soul
-
Feb 18th, 2003, 09:18 PM
#5
Junior Member
I've used quite a few Validation controls in ASP.net and they use client-side script by default. I haven't used the "DataTypeCheck" before, but I don't see why it would be any different than the others. Try it out and you'll see. It's pretty obvious when a post-back occurs...
-
Feb 18th, 2003, 10:03 PM
#6
PowerPoster
Originally posted by DevGrp
Sorry, I'm not too advance when it comes to client side scripting. I just decided to learn web programming.
Same here, when the questions come in about scripting, I leave them alone. All work should be done on the server....lol.....at least that is how I see it...
-
Feb 18th, 2003, 11:03 PM
#7
Junior Member
Actually what I meant was that the ASP.net validation controls write the client-side script for you. With the ones I have tried, like RequiredFieldValidators and RangeValidators, all you have to do is put in the tag. The client-side script is handled automatically. (unless you specifiy a server-side function to handle the validation).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|