Results 1 to 7 of 7

Thread: Validation Help..

  1. #1

    Thread Starter
    Lively Member harsoni's Avatar
    Join Date
    Oct 2000
    Posts
    118

    Question 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

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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

  3. #3

    Thread Starter
    Lively Member harsoni's Avatar
    Join Date
    Oct 2000
    Posts
    118
    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

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    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

  5. #5
    Junior Member
    Join Date
    Feb 2003
    Posts
    16
    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...

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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...

  7. #7
    Junior Member
    Join Date
    Feb 2003
    Posts
    16
    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
  •  



Click Here to Expand Forum to Full Width