• Make Order

  • order processing

  • Approve and Get
    your Order
Order Now

Hands-On Project

Chapter 2
Project 2-1
In this project,you will create a class and use the variable defined within the class in aWeb Form. 1. Start your Web development editor and open your chapter2 Web site, if it is not already open.
2. Create a new class item in your project and name it ch2_proj1_class.vb. After it is created, your Web development editor will store the class in the App_Code directory.
3. Open the class ch2_proj1_class.vb file. Create a public instance variable named StoreAddress that is a String data type. Assign the value 555 Michigan Avenue, Chicago, IL 60016 to the variable.
4. Click the Save All button to save the class file.
5. In the Solution Explorer window, right-click the ch2_ proj1.aspx page in the ch2_ proj2 folder and click View Code.
6. In the Page_Load procedure add the code that follows to create a new object named ch2_proj1_newclass, based on the ch2_proj1_class. Because the variable contains an object, the keyword New must be used to instantiate the object from a class. As you type each period, notice that the IntelliSense list box appears. Dim ch2_proj1_newclass As New ch2_proj1_class
7. Type the code that follows to retrieve the values from the new class and assign the variable from the class to the text property of the lblContact label control in the Web page. (Note:You need to use the ToString method to retrieve the value from the string stored in the variable.) lblContact.Text = ch2_proj1_newclass.StoreAddress.ToString
8. Click the Save All button. In the Solution Explorer window, right-click the ch2_proj1.aspx page and click View in Browser. Right-click the page and click View Source to view the client-side code sent from the Web server to the browser.

Project 2-2
In this project, you will create a custom error message and enable your Web application configuration file to detect HTTP status errors.
1. Start your Web development editor and open your chapter2 Web site, if it is not already open.
2. Open the code behind the page for the Web.config file. Locate the customErrors node and modify the code (as shown in the code that follows) to redirect the visitor who has been denied access to a Web resource. (Note: Do not create a new customErrors node.) <customErrors defaultRedirect=”~/ch2_home.aspx” mode=”On”> <error statusCode=”404″ redirect=”~/ch2_proj2/ch2_proj2_404.aspx” /> </customErrors>
3. Create a new Web page named ch2_proj2_404.aspx in the ch2_proj2 folder. Add graphics and content to indicate to the visitor that the resource has not been found. Provide the visitor with a link back to the ch2_home.aspx page. (Hint:You can use the NavigateUrl property of the HyperLink control to configure the URL.)
4. Click the Save All button.
5. View the Web page in an external browser. In the URL, change the ch2_proj2.aspx to ch2_proj2_test.aspx and press the Enter key (or click the Go button in some browsers). Since this page does not exist, you should be redirected to the ch2_proj2_ 404.aspx page.
6. Print your source code for the ch2_proj2_404.aspx page and the source code for the Web.config file. 7. Save your Web.config file as ch2_proj2_Web.config in the ch2_proj2 folder. Then open the Web.config file and delete the entire customErrors node. Click the Save All button. This will return the Web configuration file to the default configuration.
8. Close any open pages.

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes