Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom webcontrol and Validators

Custom webcontrol and Validators

Scheduled Pinned Locked Moved ASP.NET
helptutorialworkspace
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Henrique de Aguiar
    wrote on last edited by
    #1

    Hi guys! Well, I've built a custom webcontrol and i'm having a little trouble with validation. Actually, validations works fine. (I've setup the ValidationProperty attribute). The problem is that if use a RegularExpressionValidator, for example, and I fill the field incorrectly, the postback occurs and then validation get in action. But, I want it in the client side. If i use, the same validator for a TextBox control, works fine: occurs the validation AND then if successful, postback. I don't know what I doing wrong here. I will appreciate any kind of help. PS. sorry for my poor english... =) ..:: Bocão

    N M 2 Replies Last reply
    0
    • H Henrique de Aguiar

      Hi guys! Well, I've built a custom webcontrol and i'm having a little trouble with validation. Actually, validations works fine. (I've setup the ValidationProperty attribute). The problem is that if use a RegularExpressionValidator, for example, and I fill the field incorrectly, the postback occurs and then validation get in action. But, I want it in the client side. If i use, the same validator for a TextBox control, works fine: occurs the validation AND then if successful, postback. I don't know what I doing wrong here. I will appreciate any kind of help. PS. sorry for my poor english... =) ..:: Bocão

      N Offline
      N Offline
      Neel07
      wrote on last edited by
      #2

      If you want client side validation i.e. without being postback then write a javascript function add this function to the control you want to validate. string jscript="Javascript:fn();"; controlname.Attributes.Add("onchange",jscript); Share knowledge to enhance your learning

      H 1 Reply Last reply
      0
      • N Neel07

        If you want client side validation i.e. without being postback then write a javascript function add this function to the control you want to validate. string jscript="Javascript:fn();"; controlname.Attributes.Add("onchange",jscript); Share knowledge to enhance your learning

        H Offline
        H Offline
        Henrique de Aguiar
        wrote on last edited by
        #3

        But i want o use a RE validator. Do I really have to implement a javascript function to do that? And more, why with standard control works? ..:: Bocão

        1 Reply Last reply
        0
        • H Henrique de Aguiar

          Hi guys! Well, I've built a custom webcontrol and i'm having a little trouble with validation. Actually, validations works fine. (I've setup the ValidationProperty attribute). The problem is that if use a RegularExpressionValidator, for example, and I fill the field incorrectly, the postback occurs and then validation get in action. But, I want it in the client side. If i use, the same validator for a TextBox control, works fine: occurs the validation AND then if successful, postback. I don't know what I doing wrong here. I will appreciate any kind of help. PS. sorry for my poor english... =) ..:: Bocão

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Hi there, At the server side, the validator validates your custom control based on the property specified in the ValidationProperty attribute. At the client side, it relies on the value attribute of the element specified in the controltovalidate property of the validator. If your control renders to an element at the client side which does not support the value attribute, then validation at the client side always succeeds. The reason as to the textbox can be validated at the client side is that the input text element does have the value attribute, so the validator can get the value of the input text to validate. If you want to validate at the client side, you might consider using a custom validator and provide your own client side validation function. For more information, you can see the RegularExpressionValidatorEvaluateIsValid function in the WebUIValidation.js file.

          H 1 Reply Last reply
          0
          • M minhpc_bk

            Hi there, At the server side, the validator validates your custom control based on the property specified in the ValidationProperty attribute. At the client side, it relies on the value attribute of the element specified in the controltovalidate property of the validator. If your control renders to an element at the client side which does not support the value attribute, then validation at the client side always succeeds. The reason as to the textbox can be validated at the client side is that the input text element does have the value attribute, so the validator can get the value of the input text to validate. If you want to validate at the client side, you might consider using a custom validator and provide your own client side validation function. For more information, you can see the RegularExpressionValidatorEvaluateIsValid function in the WebUIValidation.js file.

            H Offline
            H Offline
            Henrique de Aguiar
            wrote on last edited by
            #5

            Oh... Damn... Allright. I have already seen the WebUIValidation.js file, but enough i thougt. And i don't want to "hack" it. Thank you for the tips... I'm gonna try a few ideas and, if works, i come back and tell you. Have a nice day. ..:: Bocão

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups