Creating the Northwind Solution


ASP.NET Developer's JumpStart
By Paul D. Sheriff, Ken Getz
Table of Contents
Chapter 6.  Introduction to ASP.NET

To demonstrate working with Web Forms and server controls, in this section you'll add a main page to the Northwind Trading Company application that includes links to pages you'll add in later chapters. In addition, you'll create a login page that you'll use in several later chapters, adding login capabilities to the application.

To get started, load the Northwind.sln solution you have been working on up to this point. Follow these steps to add Main.aspx and controls to the page:

  1. Select Project, Add Web Form from the menu bar.

  2. Set Name to Main.aspx and click Open.

  3. Add the following controls:

    Control Property Value
    Label ID Label1
      Text Northwind Traders
      Font.Bold True
      Font.Size Large
    Hyperlink ID hypProducts
      Text Products
      NavigateURL Products.aspx
    Label ID Label2
      Text Maintenance
      Font.Bold True
      Font.Size Small
    Hyperlink ID hypLogin
      Text Login
      NavigateURL Login.aspx
    LinkButton ID lnkLogout
      Text Log Out
      Visible False
    Hyperlink ID hypEmpMaint
      Text Employee
      NavigateURL EmpMaint.aspx
      Visible False
    Hyperlink ID hypPwdChange
      Text Change Password
      NavigateURL PWDChange.aspx
      Visible False

  4. To set Main.aspx as the startup page, right-click Main.aspx in the Solution Explorer window and then select Set as Start Page from the context menu.

  5. In the Solution Explorer window, right-click Global.asax and select View Code from the context menu. Modify the Session_Start() procedure in the code window, like this:

     Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)     Session("LoginID") = String.Empty     Session("Password") = String.Empty End Sub 
  6. In the Solution Explorer window, double-click the Login.aspx page you created in the last chapter to load the page into the page designer.

  7. Change the Text property of the First Name label to Login ID.

  8. Change the Text property of the Last Name label to Password.

  9. Click the text box named txtFirst.

  10. Change the ID property to txtLoginID.

  11. Click the text box named txtLast.

  12. Change the ID property to txtPassword.

  13. Change the Textmode property to Password.

  14. Change the lblName label control at the bottom of the form to the name lblError. Reset the BorderStyle property to None.

  15. Change the Click event procedure to the following code:

     Private Sub btnLogin_Click( _  ByVal sender As System.Object, _  ByVal e As System.EventArgs) Handles btnLogin.Click     Server.Transfer("Main.aspx") End Sub 

Finally, it's time to test your application, just to make sure the login page redirects you correctly to the main page. Follow these steps to verify that things are "hooked up" correctly:

  1. Press F5 to run the project.

  2. On the main page, click the Log In link to navigate to Login.aspx.

  3. On the login page, click the button to navigate back to the main page.

  4. Close any open pages when you're done.


    ASP. NET Developer's JumpStart
    ASP.NET Developers JumpStart
    ISBN: 0672323575
    EAN: 2147483647
    Year: 2002
    Pages: 234 © 2008-2017.
    If you may any questions please contact us: