开发者

Validation on a mobile 6 phone?

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 disp开发者_运维百科lay the validation errors to the user?


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

  • http://www.codeplex.com/ValidationFramework
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜