Creating an Integrated Web Application - PowerPoint PPT Presentation

1 / 47
About This Presentation
Title:

Creating an Integrated Web Application

Description:

Become familiar with an integrated Web application that contains multiple Web forms ... Deploy a completed Web application on a production Web server ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 48
Provided by: NATEU
Learn more at: https://www.tarleton.edu
Category:

less

Transcript and Presenter's Notes

Title: Creating an Integrated Web Application


1
Chapter 11
  • Creating an Integrated Web Application

2
Objectives
  • In this chapter, you will
  • Become familiar with an integrated Web
    application that contains multiple Web forms
  • Understand how to transfer processing from one
    Web form to another
  • Learn how to share data values across multiple
    Web forms

3
Objectives
  • In this chapter, you will
  • Learn how to insert records simultaneously in
    master and detail tables
  • Learn how to add template columns to a DataGrid
    control
  • Implement security using forms-based
    authentication
  • Deploy a completed Web application on a
    production Web server

4
The Clearwater Traders Integrated Web Application
  • The Start Page of the Clearwater Traders Web
    application is the Clearwater.htm static Web page
  • This Web application supports two primary
    database-driven processes
  • Allowing customers to place new orders
  • Allowing customers to view their existing orders

5
The Clearwater Traders Integrated Web Application
  • Figure 11-1 shows the Clearwater Traders Web
    application

6
The Clearwater Traders New Customer Order Process
  • When the user clicks the Catalog hyperlink on the
    Clearwater.htm static Web page, the Catalog.aspx
    Web form appears
  • The Catalog.aspx Web form allows the user to view
    merchandise items, determine whether items are in
    stock, and select items to order

7
The Clearwater Traders New Customer Order Process
8
The Clearwater Traders New Customer Order Process
  • When the user clicks the View Cart Place Order
    button on the Catalog.aspx Web form, the
    ShoppingCart.aspx Web form appears 
  • Figure 11-3 shows the ShoppingCart.aspx Web form

9
The Clearwater Traders New Customer Order Process
  • When the user clicks the Place your order now
    button, the Login.aspx Web form appears
  • Figure 11-4 shows the Login.aspx Web form

10
The Clearwater Traders New Customer Order Process
  • The ConfirmOrder.aspx Web form summarizes the
    order items and displays the total order cost
  • Figure 11-6 shows the ConfirmOrder.aspx Web form

11
The Clearwater Traders New Customer Order Process
  • On the ConfirmOrder.aspx Web form, the user can
    click Continue Shopping to redisplay the
    Catalog.aspx Web form, or Confirm your order to
    display the ProcessOrder.aspx Web form
  • Figure 11-7 shows the ProcessOrder.aspx Web form

12
The Clearwater Traders View Order Process
  • After the user successfully logs on, the
    ViewOrders.aspx Web page appears, which
    summarizes the details of the customers orders
  • Figure 11-8 shows the ViewOrders.aspx Web form

13
Running the Integrated Web Application
  • Before creating the Clearwater Traders Web
    application, you will first install a completed
    version of the application on your Web server and
    then run the application to become familiar with
    its operation
  • Then create a new customer order and place an
    order
  • After that, place an order as a new customer
    rather than as a returning customer

14
Creating and Configuring the Clearwater Traders
Tutorial
  • To make it easier to create the Clearwater
    Traders Web application, you can base your
    application on partially completed Web form files
    that are on the Data Disk
  • These files contain Web form elements and use
    Web/database programming concepts that you
    learned to create in earlier chapters

15
Creating and Configuring the Clearwater Traders
Tutorial
  • First, start Visual Studio .NET and create a new
    Web application project named Clearwater
  • Then add to the project the Web forms on which
    the integrated application will be based
  • Then update data connections and generate
    required data sets in the Web forms

16
Displaying Different Web Forms Within an
Integrated Web Application
  • When the user clicks View Cart Place Order on
    the Catalog.aspx Web form, a program command
    executes that displays the ShoppingCart.aspx Web
    form
  • ASP.NET supports two different methods that
    transfer application processing from a source Web
    page or form to a target page or form
  • Response.Redirect method
  • Server.Transfer method

17
The Response.Redirect Method
  • In ASP.NET, the HttpResponse class stores
    information about an ASP.NET operation
  • The Redirect method instructs the client browser
    to display a different Web page
  • The general syntax to call the Response.Redirect
    method isResponse.Redirect("target_URL")

18
The Response.Redirect Method
  • Figure 11-10 shows the Response.Redirect method
    processing steps

19
The Server.Transfer Method
  • In ASP.NET, the Server object is a system object
    that provides access to methods and properties
    that relate to the Web server
  • The Server.Transfer method transfers processing
    directly from the current Web form to a target
    Web form
  • The general syntax for calling the
    Server.Transfer method isServer.Transfer("target
    _Web_form_URL")

20
The Server.Transfer Method
  • Figure 11-11 shows the Server.Transfer method
    processing steps

21
Sharing Data Values Across Multiple Web Forms
  • Web applications that contain multiple Web forms
    usually need to share data values among the
    different forms
  • There are three approaches for sharing data
    values among different forms
  • Server-side cookies
  • Session variables
  • Application variables

22
Server-Side Cookies
  • Cookie a data item about a Web server session
    that the client computer stores
  • Server-side cookies cookies that server-side
    programs create on the client workstation
  • In a Web form, the Response.Cookies method is
    called to create a server-side cookie
  • A cookie contains data values as variable
    name/value pairs

23
Server-Side Cookies
  • The following general command creates a new
    cookie name/value pairResponse.Cookies("variable
    _name").Value variable_value
  • The Request.Cookies method is used in a Web form
    event handler to retrieve the value of a cookie
    variable
  • This method has the following general
    syntaxobject Request.Cookies("variable_name").
    Value

24
Session Variables
  • Session variable a value that contains specific
    information about a browser session
  • When the browser first requests a Web form
    (.aspx) page from the Web server, a cookie named
    SessionID is created on the browser
  • SessionID cookie stores the browser/Web server
    session ID, which is a value that uniquely
    identifies the session

25
Session Variables
  • Web servers structure session variables as
    name/value pairs
  • The following command is used to create a new
    session variableSession("variable_name")
    variable_value
  • To retrieve session variable values, the session
    variable value is assigned to an object
  • The following command is used to assign the value
    of a session variable to an objectobject
    Session("variable_name")

26
Application Variables
  • Application variable stores a value on the Web
    server that is associated with a specific Web
    application and is accessible to all application
    users
  • The following syntax is used to create a session
    variableApplication("variable_name")
    variable_value

27
Application Variables
  • The following syntax is used to reference a
    session variableobject Application("variable_n
    ame")
  • The following syntax is used to remove a session
    variableApplication.Remove("variable_name")

28
Inserting Master-Detail Records Simultaneously
  • In a database master-detail relationship, a
    master record in one database table has many
    related detail records in another table
  • Often when Web developers insert records in a
    master table, they must simultaneously insert
    related records in a detail table
  • Inserting master-detail records simultaneously
    becomes tricky when the DBMS automatically
    generates a surrogate key value

29
Retrieving and Storing Oracle9i Sequence Values
  • To use an Oracle9i sequence to generate surrogate
    key values automatically, the NEXTVAL sequence
    pseudocolumn is used within the SQL INSERT
    command to retrieve the next sequence value
  • This command has the following syntaxINSERT
    INTO tablename (column1_name, column2_name)VALUES
    (sequence_name.NEXTVAL, column2_value)

30
Retrieving and Storing Oracle9i Sequence Values
  • Another way to retrieve the next value in an
    Oracle9i sequence is to use a SELECT query that
    has the following syntaxSELECT
    sequence_name.NEXTVAL FROM DUAL
  • To save the next sequence value in a local
    variable, Web developers create a SQLCommand
    object in which the CommandText property value is
    the SQL query that retrieves the next sequence
    value
  • Then, the SQLCommand object is executed using the
    ExecuteScalar method

31
Retrieving and Storing Access AutoNumber Values
  • To insert master-detail records in a Web
    application project simultaneously using an
    Access database, the master record is inserted as
    usual
  • Then the last AutoNumber value inserted by the
    application is retrieved and assigned to a local
    variable using the SQL query SELECT _at__at_IDENTITY

32
Retrieving and Storing Access AutoNumber Values
  • To store the next AutoNumber value in a local
    variable, the following general syntax is
    usedSQLCommand.CommandText SELECT
    _at__at_IDENTITYDim variable_name As Integer
    CInt(SQLCommand.ExecuteScalar())

33
Simultaneously Inserting the Master and Detail
Records
  • When the user clicks Confirm your order on the
    ConfirmOrder.aspx Web form, the buttons event
    handler transfers processing to the
    ProcessOrder.aspx Web form
  • The ProcessOrder.aspx Web form contains commands
    to insert the new order and order line records
    into the database
  • The customer ID (C_ID) field is a foreign key in
    the ORDERS table

34
Simultaneously Inserting the Master and Detail
Records
  • To insert the new order record in the ORDERS
    table, the system must determine the C_ID value
    for the current customer
  • The system determines the customers ID value
    using a query that has a search condition based
    on the values that the user enters in the User
    Name and Password TextBox controls on the
    Login.aspx Web form

35
Creating Template Columns in a DataGrid Control
  • A DataGrid template column is used to display
    calculated values or alternate values from those
    that the database stores
  • When a template column is created, HTML tags are
    used to specify the data that appears in the
    column
  • A template column allows you to display almost
    any values on a DataGrid control flexibly 
  • A new template column in a DataGrid is created
    with the Property Builder visual configuration
    tool

36
Creating a New Template Column
  • To create a new template column, you may open the
    Property Builder visual configuration tool,
    select the Columns page, then add and configure
    the template column
  • You can specify the template columns position
    and other properties within the DataGrid

37
Defining the Web Server Control Template
  • Web server control templates are created to
    specify how DataList controls display data
  • A Web server control template can contain
    different templates to specify different regions
    within the column 
  • Data columns are referenced using the
    DataBinder.Eval method, which has the following
    general syntaxlt DataBinder.Eval(Container.Dat
    aItem, "column_name") gt

38
Implementing Form Security
  • ASP.NET supports forms authentication, which is a
    process that allows the system to authenticate
    user identities once
  • When implementing forms authentication in a Web
    application project, all Web forms that require
    user authentication are placed in a secure folder
  • A secure folder is a folder that contains forms
    that only authenticated users can view

39
Implementing Form Security
  • An anonymous user is a user who has not yet been
    authenticated
  • When an anonymous user connects to the Web
    application, the user cannot access the Web forms
    in the secure folder until he or she is
    authenticated
  • The user authenticates his or her identify using
    a login form

40
Configuring Forms Authentication in a Web
Application Project
  • To configure a Web application project to use
    forms authentication, the projects Web.config
    file is modified
  • First, forms authentication in the project is
    enabled by modifying the mode attribute of the
    ltauthenticationgt element as followsltauthenticati
    on mode"Forms"gt

41
Configuring Forms Authentication in a Web
Application Project
  • To specify the name of the login form, a ltformsgt
    element is created within the ltauthenticationgt
    element, and its loginUrl attribute is specified
    as the URL and filename of the login form
  • The ltformsgt element uses the following
    syntaxltforms loginUrl"login_form_url" /gt

42
Modifying Form Commands to Implement Forms
Authentication
  • When Web developers implement forms
    authentication in a Web application project, they
    need to modify how the form commands transfer
    processing to other forms
  • To enable forms authentication, the commands that
    transfer processing from the login form to the
    secure forms need to be modified if the login
    form authenticates multiple secure forms

43
Deploying a Completed Web Application to a
Production Web Server
  • In deploying a Web application, Web developers
    move the required program files to the production
    Web site
  • Then, they configure the production Web site so
    it can accept browser requests and return the
    required application files
  • Web programs are developed on a personal Web
    server
  • Then, after testing and debugging, the programs
    are deployed on a production Web server

44
Configuring the Production Web Server
  • To run ASP.NET Web application projects, the
    production Web server must have ASP.NET and the
    .NET common language runtime installed
  • To configure the Web server, the production
    project folder is created, which is the folder on
    the Web server that contains the production
    application files
  • Then, a new Web application that is associated
    with the new production project folder is created

45
Moving the Production Application Files to the
Web Server
  • When deploying a Web application project to a
    production Web server, the projects compiled
    (binary) files must be placed on the Web server
  • Then, the production application files need to be
    moved to the production project folder

46
Summary
  • To transfer processing to a different Web page in
    a Web application project, the Response.Redirect
    method or the Server.Transfer method can be used
  • Server-side cookies and session variables can be
    used to share data values among different Web
    forms in a project
  • Application variables are used to store values
    that all application users access, and that
    require small amounts of storage space and quick
    access times

47
Summary
  • To insert a master record and detail records
    simultaneously when the master records primary
    key is a surrogate key, the surrogate key value
    is stored as a local variable, and then the local
    variable value is used to insert the detail
    records
  • Forms authentication allows the system to
    authenticate a users identity once, and then
    allows the user to access his or her secure
    information for the duration of the browser
    session
Write a Comment
User Comments (0)
About PowerShow.com