Mgmt 362a Bookstore Application: Middle Tier - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

Mgmt 362a Bookstore Application: Middle Tier

Description:

Write the functionality for the middle tier, using Visual Basic code. ... Parameter Source: drop-down list. Session field: textbox ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 33
Provided by: Pear179
Category:

less

Transcript and Presenter's Notes

Title: Mgmt 362a Bookstore Application: Middle Tier


1
31
  • Mgmt 362a Bookstore Application Middle Tier
  • Introducing Code-Behind Files and Databound Web
    controls

2
Objectives
  • In this tutorial you will learn
  • Write the functionality for the middle tier,
    using Visual Basic code.
  • Modify code-behind files in a Web application.
  • Use databound Web controls.

3
31.2 Changing the Class Name in Books.aspx.vb
  • Code-behind files
  • Contains the code corresponding to an ASPX page
  • Written in a .NET language, such as Visual Basic

4
31.2 Changing the Class Name in Books.aspx.vb
(Cont.)
Figure 31.2 Code-behind files for the
Books.aspx and BookInformation.aspx pages in the
Solution Explorer.
5
31.2 Changing the Class Name in Books.aspx.vb
(Cont.)
Figure 31.3 Code-behind file for the Books.aspx.
6
31.2 Changing the Class Name in Books.aspx.vb
(Cont.)
  • Page class
  • Defines the basic functionality for an ASPX page
  • Located in the System.Web.UI namespace
  • Provides properties, methods and events that are
    useful to creating Web-based applications

7
31.2 Changing the Class Name in Books.aspx.vb
(Cont.)
Figure 31.4 Changing the applications class
name.
8
31.2 Changing the Class Name in Books.aspx.vb
(Cont.)
Figure 31.5 Changing the Books.aspx Inherits
statement.
9
31.2 Defining the Click Event Handlerfor the
Books.aspx Page
  • Session items
  • Used for sharing values among ASPX pages
  • Key-value pair
  • Associates a value with a corresponding name
    (key) which identifies the value.
  • Response object
  • Inherited from class Page
  • Redirect method
  • Takes the URL of the page to which the client
    browser redirects as an argument

10
31.2 Defining the Click Event Handlerfor the
Books.aspx Page (Cont.)
Figure 31.6 informationButton_Click event
handler definition.
11
31.2 Creating a Databound ListBox usingan
ObjectDataSource
  • Binding data to an existing ListBox
  • Black triangle in the upper-right corner
  • Click Choose Data Source to open the Data Source
    Configuration Wizard

12
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.7 Creating a databound ListBox in the
GUI.
13
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.8 Creating a new data source.
14
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.9 Choosing a data source type.
15
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.10 Choosing a business object.
16
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
  • Define Data Methods screen
  • Specifies which method of the business object
    will be used to obtain the data
  • GetData method

17
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.11 Defining data methods.
18
31.2 Creating a Databound ListBox usingan
ObjectDataSource (Cont.)
Figure 31.12 Finish defining Data Source for
ListBox.
19
31.3 Defining the Page_Load Event Handler forthe
BookInformation.aspx Page
Figure 31.13 BookInformation class.
20
31.3 Defining the Page_Load Event Handler for the
BookInformation.aspx Page (Cont.)
  • Page_Load event handler
  • Invoked automatically when an ASPX page is loaded

21
31.3 Defining the Page_Load Event Handler for the
BookInformation.aspx Page (Cont.)
Figure 31.14 BookInformation class.
22
31.3 Defining the Page_Load Event Handler for the
BookInformation.aspx Page (Cont.)
Figure 31.15 Page_Load event handler modified
to set a parameter value and open a database
connection.
23
31.3 Defining the Page_Load Event Handler for the
BookInformation.aspx Page (Cont.)
Figure 31.16 Definition of the
bookListButton_Click event handler.
24
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource
Figure 31.17 Select ltNew Data Sourcegt in the
Choose Data Source TextBox.
25
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.18 Defining the data methods.
26
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
  • Defining data parameters
  • Define Parameters dialog
  • Parameter Source drop-down list
  • Session field textbox

27
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.19 Defining the querys parameters.
28
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
  • Specifying displayed fields
  • DetailsView Tasks menu
  • Click Edit Fields to display the Fields dialog
  • red X Button
  • Removes items from the Selected fields ListBox

29
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.20 Modifying the displayed fields in
the DetailsView.
30
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.21 Removing displayed fields from the
DetailsView.
31
31.3 Creating a Databound DetailsView Usingan
ObjectDataSource (Cont.)
Figure 31.22 Final Fields dialog.
32
Finishing the Bookstore App
  • When you complete Tutorial 31 that finishes the
    Bookstore app and the assignment.
  • For Assignment 12
  • turn in the snapshots of the two pages correctly
    executing
  • and a copy of each of the code from the two code
    behind the files (not necessary to turn in th
    HTML)
Write a Comment
User Comments (0)
About PowerShow.com