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. ErrorProvider logic to avoid DialogResult.OK button completion?

ErrorProvider logic to avoid DialogResult.OK button completion?

Scheduled Pinned Locked Moved C#
questioncsharpasp-net
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.
  • C Offline
    C Offline
    Chesnokov Yuriy
    wrote on last edited by
    #1

    What is the logic as in ASP.NET application the page will not be sent if any control is not validated? I've got dialog box with Ok and Cancel button. If any validated item (edit box) is not valid, then Ok button click should not close dialog box but only Cancel can do that?

    Чесноков

    M 1 Reply Last reply
    0
    • C Chesnokov Yuriy

      What is the logic as in ASP.NET application the page will not be sent if any control is not validated? I've got dialog box with Ok and Cancel button. If any validated item (edit box) is not valid, then Ok button click should not close dialog box but only Cancel can do that?

      Чесноков

      M Offline
      M Offline
      Michael Eber
      wrote on last edited by
      #2

      Your question is a little confusing but I'll take a stab at your question. You cannot use the basic MessageBox for what you want to do. You creat a form, design it as a dialog, and put your own code in the form to accomplish that. Now if you are really sharp then you can do something like this: Create the form and make the constructor require an IValidator class passed in the constructor. Add an OkayButton CancelButton and make the OkayButton disabled. Define your interface for IValidator. The Validator will implement it's own rules for what is valid and what is invalid. As the data is entered into the form, the data is passed into the validator such that OkayButton.Enabled = Validator.IsValid( entryBox.Text ); As long as the data is valid (or once it is valid) the button will light up. As long as it is invalid it remains disabled. By doing this, you have an extensible dialog box that can have an infinite number of validation rules without ever having to change a line of code in the control.

      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