Exercise: Maintaining state within page - max 3 goes

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> ASP.NET webforms - VB  (27 exercises)
Topic ==> Maintaining state  (1 exercise)
Level ==> Average difficulty
Course ==> ASP.NET WebForms - VB
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Create a new website, and add the 4 files in the above folder into it.

Create a new web page called frmNew.aspx, which asks a user to type in a film name.  If the user leaves the text box blank, you should display an error like this:

ASP.NET 4.0 - Visual Basic exercise - Maintaining state (image 1)

Here we've left the film blank twice - we have one more go

Use a hidden literal to remember the number of attempts in view state (remember to initialise it to 0 on first page load).

If you fail to type something in more than 3 times, you should see an error like this:

ASP.NET 4.0 - Visual Basic exercise - Maintaining state (image 2)

Set the ENABLED property of the textbox and button in code to achieve this

If, on the other hand, you type in a film name, you should see it confirmed back to you:

ASP.NET 4.0 - Visual Basic exercise - Maintaining state (image 3)

Your font can be smaller - this uses the ImportantMessage class

Save and close your website!

This page has 0 threads Add post