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. CustomValidator ClientSideFunction property isn't working with ValidationSummary control

CustomValidator ClientSideFunction property isn't working with ValidationSummary control

Scheduled Pinned Locked Moved ASP.NET
phpdatabasecomsysadmintools
4 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.
  • M Offline
    M Offline
    Mark J Miller
    wrote on last edited by
    #1

    I have a CustomValidator control which is declared like this: <asp:CustomValidator ID="m_DelayCodeValidator" runat="server" ControlToValidate="m_DelayCode" Text="*" ErrorMessage="Delay code" EnableClientScript="true" ClientValidationFunction="m_DelayCode_Validate" OnServerValidate="m_DelayCode_Validate" /> I have a ValidationSummary control on the page as well. But when I try and submit the form the error message from my custom validator isn't listed with the other error messages in the ValidationSummary. The custom validation script isn't being called either - the script is only called when the value of ControlToValidate changes. I need the script called on submit as well like the other validators are. ValidationSummary: <asp:ValidationSummary ID="validationSummary" runat="server" DisplayMode="BulletList" HeaderText="Please enter the required values:" /> ClientValidationFunction: function m_DelayCode_Validate(sender, args) { if(m_DowntimeCode.options[m_DowntimeCode.selectedIndex].text != "Opportunity Maintenance") { args.IsValid = true; return; } if(args.Value == "" || args.Value == null || args.Value == undefined) args.IsValid = false; else args.IsValid = true; }

    Code responsibly: OWASP.org Mark's blog: developMENTALmadness.blogspot.com

    C 1 Reply Last reply
    0
    • M Mark J Miller

      I have a CustomValidator control which is declared like this: <asp:CustomValidator ID="m_DelayCodeValidator" runat="server" ControlToValidate="m_DelayCode" Text="*" ErrorMessage="Delay code" EnableClientScript="true" ClientValidationFunction="m_DelayCode_Validate" OnServerValidate="m_DelayCode_Validate" /> I have a ValidationSummary control on the page as well. But when I try and submit the form the error message from my custom validator isn't listed with the other error messages in the ValidationSummary. The custom validation script isn't being called either - the script is only called when the value of ControlToValidate changes. I need the script called on submit as well like the other validators are. ValidationSummary: <asp:ValidationSummary ID="validationSummary" runat="server" DisplayMode="BulletList" HeaderText="Please enter the required values:" /> ClientValidationFunction: function m_DelayCode_Validate(sender, args) { if(m_DowntimeCode.options[m_DowntimeCode.selectedIndex].text != "Opportunity Maintenance") { args.IsValid = true; return; } if(args.Value == "" || args.Value == null || args.Value == undefined) args.IsValid = false; else args.IsValid = true; }

      Code responsibly: OWASP.org Mark's blog: developMENTALmadness.blogspot.com

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I found the best thing is to dig in to the js that ASP.NET generates, and to write my own method that duplicates their calls but adds my own, if I want that degree of control.

      Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

      M 1 Reply Last reply
      0
      • C Christian Graus

        I found the best thing is to dig in to the js that ASP.NET generates, and to write my own method that duplicates their calls but adds my own, if I want that degree of control.

        Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

        M Offline
        M Offline
        Mark J Miller
        wrote on last edited by
        #3

        Thanks for your suggestion. It led me to find a property I hadn't noticed as part of the CustomValidator control - ValidateEmptyText. Setting it to true fixes the problem for me. I guess I neglected to mention that the value of the default option was an empty string. I appreciate the help.

        Code responsibly: OWASP.org Mark's blog: developMENTALmadness.blogspot.com

        C 1 Reply Last reply
        0
        • M Mark J Miller

          Thanks for your suggestion. It led me to find a property I hadn't noticed as part of the CustomValidator control - ValidateEmptyText. Setting it to true fixes the problem for me. I guess I neglected to mention that the value of the default option was an empty string. I appreciate the help.

          Code responsibly: OWASP.org Mark's blog: developMENTALmadness.blogspot.com

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Glad to help :-)

          Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

          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