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. General Programming
  3. C#
  4. CustomValidator

CustomValidator

Scheduled Pinned Locked Moved C#
csharpasp-nethelplearning
2 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.
  • U Offline
    U Offline
    User 3400231
    wrote on last edited by
    #1

    Hi I'm a newbie c# programmer and have written a custom validator to validate 2 controls on a web form. I have other controls too on the same form which use the standard ASP.Net validation controls and they work perfectly however, although my custom validator works and writes the error messages to the web form, it also wants to fire off the addVehicleToDB method which is called by clicking the Submit button. This is ok of course if data entry is correct but it happens even when e.IsValid = false;! Obviously I am not fully understanding the order in which events happen so if someone could point me in the right direction that would be great. Here is my custom validator function which is linked to a text box: public void ValidateModelType(Object s, ServerValidateEventArgs e) { lblNoType.Text = "got here"; //if the text box is null if (e.Value == "") { //check that model type has been selected from drop-down list if (ddlModelTypes.SelectedItem == null) { lblNoType.Text = "not valid!"; e.IsValid = false; } else { lblNoType.Text = "all ok"; e.IsValid = true; } } } Thanks Lorna

    G 1 Reply Last reply
    0
    • U User 3400231

      Hi I'm a newbie c# programmer and have written a custom validator to validate 2 controls on a web form. I have other controls too on the same form which use the standard ASP.Net validation controls and they work perfectly however, although my custom validator works and writes the error messages to the web form, it also wants to fire off the addVehicleToDB method which is called by clicking the Submit button. This is ok of course if data entry is correct but it happens even when e.IsValid = false;! Obviously I am not fully understanding the order in which events happen so if someone could point me in the right direction that would be great. Here is my custom validator function which is linked to a text box: public void ValidateModelType(Object s, ServerValidateEventArgs e) { lblNoType.Text = "got here"; //if the text box is null if (e.Value == "") { //check that model type has been selected from drop-down list if (ddlModelTypes.SelectedItem == null) { lblNoType.Text = "not valid!"; e.IsValid = false; } else { lblNoType.Text = "all ok"; e.IsValid = true; } } } Thanks Lorna

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      InvalidForumException was thrown by your question. Please make sure you post your question in correct forum. Your post has been terminated. :-D

      Giorgi Dalakishvili #region signature my articles My blog[^] #endregion

      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