Sams Teach Yourself ASP.NET in 21 Days, Second Edition By Chris Payne
Table of Contents
Day 4. Using ASP.NET Objects with C# and VB.NET
This workshop will help reinforce the concepts covered in today's lesson. Answers can be found in Appendix A.
Quiz
1:
What are static members?
2:
Will the following code snippet work?
<html><body> Hi there! <% Response.Redirect("page2.aspx") %> </body></html>
3:
What language is the following code snippet written in?
Response.Write("Hello there!")
Exercises
1:
Create an ASP.NET page in C# that acts as a secure login page. Allow the user to enter a username and password in a text box. If they match a string you specify, redirect the user to a "success" page. Otherwise, display an error. If the user is valid, save her username in a Session variable.
2:
Write the success page in VB.NET. Display a personalized Welcome message using the Load event of the Page object and a Label control. Also inform the user of the current time and his Session ID. Check the IsPostback property of the Page object to ensure that this message is only displayed the first time he arrives at the page. Provide a button for him to log out, with a confirmation message.