Mobile .NET input verification
Verify controls are used to verify the data entered by the user.
Verification control
Verify controls are used to verify the data entered by the user.
Verify control allows you to verify input controls (such as: TextBox) and display messages when verifying fails.
Each verification control completes a specific type of verification (such as: not the specified value or is not a specified range).
By default, when the command control is clicked, the page verification is processed. Setting the CausesValidation property of the control to False When the control is clicked, you can block the validation of the page (setting the command control (possibly excited server event) at the same time without excitation verification logic).
Verify input
This page contains two forms:
<% @ PAGE
Inherits =
"System.Web.ui.MobileControls.MobilePage"%>
<% @ Register
Tagprefix = "mobile"
Namespace = "system.web.ui.mobileControls"
AskMBLY = "System.Web.Mobile"%>
SUB Page2 (Sender As Object, E AS Eventargs)
IF page.issalid then
Activeform = F2
Text2.text = "you are" & agn.text & "years old"
END IF
End Sub
script>
<
MOBILE
: Form id = "f1" runat = "server">
<
MOBILE
: CompareValidator Runat = "Server"
ControlTovAlidate = "agn"
Type = "integer"
Valuetocompare = "18"
Operator = "Greaterthanequal">
You Must Be at Least 18
MOBILE
: CompareValidator> CompareValidator>
<
MOBILE
: Label Runat = "Server"> AGE? Mobile: Label>
<
MOBILE
: TextBox ID = "Age" runat = "server" />
<
MOBILE
: Command OnClick = "Page2" Runat = "Server">
Submit Mobile: Command>
MOBILE
: Form>
<
MOBILE
: Form id = "f2" runat = "server">
<
MOBILE
: Label id = "text2" runat = "server" />
MOBILE
: Form>
The first table has a text attribute is the label control of the AGE, an input box and a submission button.
The second page is activated by clicking the submission button of the first page, and the corresponding is displayed. If the verification input is incorrect, the error message is displayed.
When the app is running on the mobile device, the two pages look like the following:
AGE?
Form 2
You are 21 year of Years Old
Validationsummary control
The previous example uses the COMPAREVALIDATOR control to verify the input information. Enter the verification of the information is defined by verifying the properties of the control ContoltovAlidate.
You can also use the properties of the Validationsummary control to verify all the input information in the form. (Function like ASP.NET)
This way you can replace the original single error display with the wrong summary information.
Verification control reference
Name
FUNCTION
CompareValidator
Compares Two Values
CustomValidator
Provides Custom Validation
Rangevalidator
Validates a Range
RegularExpressionValidator
Validates an expression
RequiredFieldValidator
Validates Required Data
Validationsummary
Displays a validation summary
To get a complete reference including attribute methods, events, and more instances, refer to the "Mobile Reference" page. (Translator Note: Refer to the original page or MSDN.)
Mobile .NET list
Moving list controls support different input and display features.
Select from List
This page has two forms:
<% @ PAGE
Inherits =
"System.Web.ui.MobileControls.MobilePage"%>
<% @ Register
Tagprefix = "mobile"
Namespace = "system.web.ui.mobileControls"
AskMBLY = "System.Web.Mobile"%>
Sub Show_price (Sender As Object, e as listcommandeventargs)
Text1.text = E.listItem.text & "=" & E.ListItem.Value
Activeform = F2
End Sub
script>
<
MOBILE
: Form id = "f1" runat = "server">
<
MOBILE
: List runat = "server"
OnItemCommand = "Show_price">
MOBILE
: List>
MOBILE
: Form>
<
MOBILE
: Form id = "f2" runat = "server"> <
MOBILE
: Label runat = "server" id = "text1" />
MOBILE
: Form>
The first table has a list of vehicles.
The second page shows the price. When you select a car on the first page, you are activated.
When this application runs on the mobile device, the two pages look like:
Form 1
Volvobmwaudi
Form 2
Volvo = $ 30,000
Move .NET selection list
The SelectionList control supports the drop-down box, the check box, and the radio button.
SelectionList
This mobile page uses SelectionList to let users choose the car:
<% @Pageinherits = "System.Web.ui.MobileControls.Mobilepage"%> <% @registerTAGPREFIX = "
MOBILE
"Namespace =" System.web.ui.mobileControls "assembly =" system.web.mobile "%>