ASP.NET Developer's JumpStart By Paul D. Sheriff, Ken Getz
Table of Contents
Chapter 25. Creating Mobile Web Applications
When you're creating mobile Web pages, you're likely to want to validate user input before submitting it to the server. The Microsoft Mobile Internet Toolkit provides the same set of validation controls you'll find in standard ASP.NET pages.
NOTE
Unlike standard ASP.NET validation controls, the Microsoft Mobile Internet Toolkit's validation controls perform no client-side validation. All validation for these controls takes place on the server.
On the first form, you might want to require that the user supply a password before retrieving other information. You can use the RequiredFieldValidator control to accomplish this. Follow these steps to add this control to your page:
Select frmMain.
Click txtPassword so that it has the focus.
Double-click the RequiredFieldValidator control in the Toolbox to add a new control immediately beneath the text box.
Set the properties for the new RequiredFieldValidator control as shown in Table 25.5.
Table 25.5. Use These Properties for the RequiredFieldValidator Control
Property
Value
ID
rvalPassword
ControlToValidate
txtPassword
ErrorMessage
Enter a password
Unless you check for the validity of the data programmatically, nothing keeps the code in the page from navigating from one form to another. Therefore, modify the cmdGo_Click procedure so that it looks like this:
Private Sub cmdGo_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles cmdGo.Click If rvalPassword.IsValid Then FillCountry() ActiveForm = frmCountry End If End Sub
Test the project: Browse the page within Internet Explorer, a handheld device simulator, or a real device. In any case, you should be required to enter a password (any password), and you should see the data loaded into the controls.