Creating the Northwind Solution

Creating the Northwind Solution
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:

Select Project, Add Web Form from the menu bar.

Set Name to Main.aspx and click Open.

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 


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.

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

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.

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

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

Click the text box named txtFirst.

Change the ID property to txtLoginID.

Click the text box named txtLast.

Change the ID property to txtPassword.

Change the Textmode property to Password.

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

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:

Press F5 to run the project.

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

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

Close any open pages when you're done.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值