none
User input validation best practices RRS feed

  • Question

  • Validatiing user input on a windows mobile 6.1 application. I am new to mobile development and am looking for best practices for validating user input such as requried fields and such. I am used to having the validation controls that you just pop on an web form. If showing a messagebox is the the case, what is the best way to put a line break in my list of fields when adding them to my string builder? By the way I am using C#. I remember way long ago when I used to do windows development with VB we used to use something like vbctrlf???.


    THanks for any help,
    Santiago
    Santiago Perez
    Wednesday, December 17, 2008 7:27 PM

Answers

  •  
    There's no special validation controls exist in WinForms on .NET CF or even on the desktop.

    Essentially it all comes down to the decision on when you want to do validation of your data entry fields - for each control after focus is switched to a different control or when a user is done with the whole entry form. For the first scenario you can use Validating event on the control. For the second, you can create some method in which you'd validate your controls on the form.

    As for CRLF it's 

    Line Feed = \n
    Carraige Return = \r


    -Alex
    Thursday, December 18, 2008 12:50 AM
  • Environment.NewLine is supported in .NET CF 3.5. 
    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    Monday, December 22, 2008 10:01 AM
    Moderator

All replies

  •  
    There's no special validation controls exist in WinForms on .NET CF or even on the desktop.

    Essentially it all comes down to the decision on when you want to do validation of your data entry fields - for each control after focus is switched to a different control or when a user is done with the whole entry form. For the first scenario you can use Validating event on the control. For the second, you can create some method in which you'd validate your controls on the form.

    As for CRLF it's 

    Line Feed = \n
    Carraige Return = \r


    -Alex
    Thursday, December 18, 2008 12:50 AM
  • SantiagoPerez said:

    If showing a messagebox is the the case, what is the best way to put a line break in my list of fields when adding them to my string builder? By the way I am using C#. I remember way long ago when I used to do windows development with VB we used to use something like vbctrlf???.

    Alex, thanks for getting back to me. DO you know what the currect constant in C# is for creating a line break when doing a messagebox?







    Santiago Perez
    Thursday, December 18, 2008 3:53 PM
  • There's no constant. You'd just insert "\n\r".

    Thursday, December 18, 2008 8:50 PM
  • Alex Yakhnin-MSFT said:

    There's no constant. You'd just insert "\n\r".

    I agree that on Windows Mobile you can pretty safely use hardcoded string value. However I think that "\r\n" is the proper way. CRLF is also Carriage Return + Line Feed i.e. "\r" + "\n".
    There is Environment.NewLine in "big" .Net framework that returns "\r\n" as well. But there is no such property in Compact Framework.
    • Edited by Serg2008 Thursday, December 18, 2008 10:17 PM Reference to "big" framework
    Thursday, December 18, 2008 10:09 PM
  • Environment.NewLine is supported in .NET CF 3.5. 
    Please mark the post that helps you, and unmark that does not. This benefits our community members.
    Monday, December 22, 2008 10:01 AM
    Moderator