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. doing validation in other file.cs

doing validation in other file.cs

Scheduled Pinned Locked Moved C#
designhelpquestion
4 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.
  • A Offline
    A Offline
    angels777
    wrote on last edited by
    #1

    hi i would like to seperate my design page from validation. so i put the validation code in e.g validate.cs design form

    private void textboxInteger_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    validate.txtIntValidate(txtPhone.text)
    }

    in my validate class

    class Validate
    {
    public bool txtIntValidate(string txt)
    {
    if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8)
    {
    e.Handled = true; // input is not passed on to the control(TextBox)
    }
    }
    }

    BUT in the validate.cs class .. how do i declare the e.. Error 3 The name 'e' does not exist in the current context

    C 1 Reply Last reply
    0
    • A angels777

      hi i would like to seperate my design page from validation. so i put the validation code in e.g validate.cs design form

      private void textboxInteger_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
      {
      validate.txtIntValidate(txtPhone.text)
      }

      in my validate class

      class Validate
      {
      public bool txtIntValidate(string txt)
      {
      if (!Char.IsDigit(e.KeyChar) && e.KeyChar != (char)8)
      {
      e.Handled = true; // input is not passed on to the control(TextBox)
      }
      }
      }

      BUT in the validate.cs class .. how do i declare the e.. Error 3 The name 'e' does not exist in the current context

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

      Good God. e is not present because you have not passed it through. Even if you did, this method should be static, assuming this class should exist at all.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      A 1 Reply Last reply
      0
      • C Christian Graus

        Good God. e is not present because you have not passed it through. Even if you did, this method should be static, assuming this class should exist at all.

        Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        A Offline
        A Offline
        angels777
        wrote on last edited by
        #3

        Thank for the reply.. can u pls show some example to get all verification done is the class ? or at least guide me on declaring or passing the e thanks

        realJSOPR 1 Reply Last reply
        0
        • A angels777

          Thank for the reply.. can u pls show some example to get all verification done is the class ? or at least guide me on declaring or passing the e thanks

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          Passing variables is a fundamental coding practice. How do you think you might want to do it? Here's a clue: The "e" parameter was passed into the function from which you're calling your validation function.

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          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