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