ALL SOFTWARE EXERCISES
- EXERCISES HOME PAGE (749)
- Access 2010 (66)
- Access VBA Macros (17)
- Advanced VBA (29)
- ASP.NET MVC (0)
- ASP.NET webforms - C# (25)
- ASP.NET webforms - VB (27)
- Excel 2010 (83)
- Excel 2013 (10)
- Excel VBA Macros (38)
- Power BI - Excel 2013 (23)
- Power BI Desktop (0)
- PowerPivot 2010 (26)
- Report Builder 3.0 (42)
- SQL (115)
- SSAS - multidimensional (21)
- SSAS - tabular (29)
- SSIS Integration Services (18)
- SSRS Reporting Services (53)
- Visual Basic 2010 (42)
- Visual C Sharp 2010 (65)
- WPF - Visual C# (20)
ASP.NET WEBFORMS - VB EXERCISES
- Master pages (2)
- CSS Styles and Style Sheets (1)
- Themes and skins (1)
- Coding web pages (2)
- Creating properties in VB (1)
- Site navigation tools (1)
- Maintaining state (1)
- Passing values between pages (3)
- Validation controls (2)
- DropDownLists and ListBoxes (2)
- Basic Gridviews (2)
- Editing using gridviews (2)
- Gridview events (3)
- ListView controls (1)
- DetailsView control (2)
- User controls (1)
Exercise: Session variables for log-on
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!
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 files in the folder shown above into it.
Create a login form called frmLogon.aspx to allow users to log on to your website:
The correct user name and password are shown filled in
If a user typed in the correct user name and password, the form should:
- set the value of the session variable called UserId equal to 1; then
- redirect you to the home page (frmHome.aspx).
Otherwise, the form should just display an error message and ask you to try logging in again.
Now attach code to your master page's Load event so that on first load the page checks for the existence of the session variable UserId. Here's what should happen:
- If this variable isn't set and this isn't the logon page, the system should redirect the user to the logon page; whereas
- If the variable is set and this is the logon page, the system should redirect the user to the home page.
You can use Request.Url.AbsolutePath.ToLower.Contains to check whether the URL for the request includes the word frmlogon.
Check that your system works! If you're ever doing this in anger yourself, a better way would be for each page apart from frmLogon.aspx to inherit from a different class (ask your trainer!).