views:

25

answers:

1

Hi

How does one do validation on a mobile 6 phone? Like in asp.net they have like validation controls and in windows forms they have the the "error" control. Yet I don't see any of these in mobile 6.

Like when I write my validation checking if statements and a error is found what do people do? Show a popup message? Or how do they display the validation errors to the user?

+3  A: 

Validation was left out of the Compact Framework. I believe you will have to roll your own. I think the best option is to extend controls like the Textbox and add a Validate method to them.

In order to roll your own you will want to impliment something like this

public interface IValidatable {
    public bool IsValid();
}

public class TextBoxRequired : Textbox, IValidatable {
    public bool IsValid() {
        return !string.IsNullOrEmpty(this.Text);
    } 
}

//
public static class ValidationHelper {
    public static bool IsFormValid(Form form) {
        //loop through all controls in the form
        //find IValidatable and call IsValid
    }
}

There are some libraries out there, but I have never used them

Bob
How would I do that? No 3rd party ones already?
chobo2
and what kind of control would I use to display the errors to the user?
chobo2
I guess that depends on what your requirements are. A very easy solution would be to show a popup screen. Another decent option would be to show a label.
Bob
Ya I was thinking of a label but I just don't have enough room to show validation errors due the limited space so I guess popup is the only option.
chobo2
Why don't you create a new question and post some images of your form. Ask for suggestions improving the layout and how validation can tie in.
Bob