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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom validator

Custom validator

Scheduled Pinned Locked Moved ASP.NET
help
3 Posts 2 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.
  • D Offline
    D Offline
    diacoboss
    wrote on last edited by
    #1

    Hi guys, I have a small problem, hope u would help me ! I'm tryin to use a custom validator on a Textbox ! Look : * The code behind now protected void first_CV_ServerValidate(object source, ServerValidateEventArgs args) { if (TextBox2.Text == "") { args.IsValid = false; } else { args.IsValid = true; } } Basically, I hoped to see a message when the Textbox is empty! But nothin happen when Click on my submit button Please help me

    A 1 Reply Last reply
    0
    • D diacoboss

      Hi guys, I have a small problem, hope u would help me ! I'm tryin to use a custom validator on a Textbox ! Look : * The code behind now protected void first_CV_ServerValidate(object source, ServerValidateEventArgs args) { if (TextBox2.Text == "") { args.IsValid = false; } else { args.IsValid = true; } } Basically, I hoped to see a message when the Textbox is empty! But nothin happen when Click on my submit button Please help me

      A Offline
      A Offline
      Adam Maras
      wrote on last edited by
      #2

      You either need to replace the CustomValidator with a RequiredFieldValidator (if you don't need any other custom logic) or set the ValidateEmptyText property of the CustomValidator to true, to force the validator to operate on empty strings. By default, the CustomValidator won't validate if the control is empty.

      Adam Maras | Software Developer Microsoft Certified Professional Developer

      D 1 Reply Last reply
      0
      • A Adam Maras

        You either need to replace the CustomValidator with a RequiredFieldValidator (if you don't need any other custom logic) or set the ValidateEmptyText property of the CustomValidator to true, to force the validator to operate on empty strings. By default, the CustomValidator won't validate if the control is empty.

        Adam Maras | Software Developer Microsoft Certified Professional Developer

        D Offline
        D Offline
        diacoboss
        wrote on last edited by
        #3

        I can't use a RequiredFieldValidator A custom validor is necessary. By setting the ValidateEmptyText I thing quite good. But In the same Page I have RequiredFieldValidator RegularFieldValidator and ValidationSummary and others controls. When I click on the submit button I have a messageBox telling me I forgot sum requiredFields or anytthing like dat. But no reference about the field concerned by the Custom Validator in this same MessageBox! So now I am asking can I show in a messageBox the message error of my CustomValidator ? thx (sorry for my english, I'm French)

        modified on Friday, August 28, 2009 9:45 AM

        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