Hot-Link Menu in Right-Side Column

Wal Mart Online → Store Pickup → Free Shipping
WM468X60_ko_static.gif


Set Start Web Page

In order to set the start page, locate your Solution Explorer and Right-Click the Web Page you wish to have as the starting page as indicated in the diagram below:

Set VB.NET Web Appliction Start Page

Figure CC-20: Setting The VB.NET Start Page in Solution Explorer


Buy from Centurion


ASPX Code to Generate Display Cart Page GUI

The following is the aspx code used to generate the Cart GUI:

<head runat="server">
    <title>Untitled</title>
    <style type="text/css">
        .style1
        {
            width: 40%;
            border-left-style: solid;
            border-left-width: 5px;
            border-right: 5px solid #C0C0C0;
            border-top-style: solid;
            border-top-width: 5px;
            border-bottom: 5px solid #C0C0C0;
        }
    </style>
</head>

<body>
    <form id="form1" runat="server">
    <div>

        <table class="style1">
            <tr>
                <td width="200px">
                    <asp:Image ID="ProductImage" runat="server" />
                </td>

                <td width="100px">
                </td>

                <td align="center" >
                    <asp:Image ID="LogoImage" runat="server" 
                        ImageUrl="http://centurion2.com/Centurion4.jpg" />
                </td>
            </tr>

            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Shopping Cart Contents:">
                    </asp:Label>
                </td>

                <td>

                </td>
            </tr>

            <tr>
                <th rowspan='5' align="left" colspan='2'>
                    <asp:ListBox ID="lstCart" runat="server" Height="118px" Width="301px">
                    </asp:ListBox>
                </th>

                <td>

                </td>
            </tr>

            <tr>
                <td>
                    <asp:Button ID="btnRemove" runat="server" Text="Remove" />
                </td>
            </tr>

            <tr>
                <td>
                </td>
            </tr>

           <tr>
                <td>
                    <asp:Button ID="btnEmpty" runat="server" Text="Empty" />
                </td>
            </tr>

            <tr>
                <td>
                </td>
            </tr>


           <tr>
                <td>
                </td>
 
                <td>
                </td>

                <td>
                </td>
            </tr>

            <tr>
                <td>
                    <asp:Button ID="btnContinue" runat="server" Text="Continue Shopping" />
                </td>
                <td>
                    <asp:Button ID="btnCheckout" runat="server" Text="Checkout" />
                </td>
                <td>
                    <asp:Label ID="lblMessage" runat="server" Forecolor="Red" 
                        EnableViewState="false" >
                    </asp:Label>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>

Help Support Mr. Centurion - Donate or Visit any Sponsor

No Purchase Necessary.

Help us keep this site operational by making a donation. Any amount is greatly appreciated. OR, if you visit our sponsor, they will make a donation for you, just for visiting.

Thank you



Display Cart Design View

Entering the above code in Source View results in the following diagram in Design View:

Display Cart Design View Web Page

Figure CC-21: Display Cart Design View Web Page


Excellent Tech Support - Centurion Approved

Sorted List Definition

A sorted list is an implementation of the Dictionary data type, where objects are maintained internally with two arrays. One array is for the keys and a second array for the associated values. Each element is a key/value pair that can accessed by its key. A key cannot be null, but the value can be.

Elements of a sorted list are sorted by the keys according to a specific Compare object. The compare object is defined when the sorted list is created. Sorted lists do not allow duplicate keys.

When an element is added to a sorted list, the element is inserted in the sorted order, and the indexing must adjust accordingly. Therefore, it is likely that the index of a key/value pair will change during the insertion/deletion process.

Operations on a sorted list tend to be slower than operations on a Hash Table because of the sorting. However, the Sorted List offers more flexibility by allowing access to the values either through the associated keys, or through the indexes.

If this branch of Computer Science is interesting to you, you may want to look at the vast selection of Computer Science books by visiting::

Centurion Online → Books → Computer Science Books

Visit Our Sponsor to Help Support Our Site - No Purchase Necessary


VB.NET Session State

Normally, HTTP doesn't keep track of items in previous browser requests. However, the server is capable of keeping track of browser variables as the user proceeds between different pages. ASP.NET uses this capability in an implementation known as Session State. ASP.NET allows the programmer to keep variables between the switching of web pages through this session state.

This application will keep track of Cart Items through the Session State variable tracking system. Session state tracks individual User Sessions by creating a Session State Object for each user's session. This object contains a session ID that uniquely identifies the session. This session ID is passed back to the browser along the the HTTP response. Then, each time the browser makes another request, the session ID is included in the request so the server can track and log the user's session as the user passes between pages.

The browser views the session ID as a Cookie, so that the session ID is included with each browser request. Although ASP.NET uses session state to keep track of user sessions, the programmer can also monitor and add to session state as desired. Some possible reasons for monitoring User Session State are:

  1. Session state can maintain information about the user. Once a user logs in, information about the user can be placed in session state from a file or database. Then each time the application is executed the user's history can be quickly accessible through the session state variables.
  2. Session state can save objects the user is working with as the user moves through different pages (like a shopping cart, for example). If session state is saved in the database, the information can be available next time the user logs on.
  3. Session state can also keep track of incomplete pending operations, so the user can pick up where they left off in the last session.

The Session State Object is accessible through the properties and methods of the HttpSessionState class. This object is accessible from a web form through the Session Property of the page.

The session state object contains a collection of items consisting of item names and values. One way to add an item to the session is to use the Add method. When using the Add method, if the item already exists, the item is updated, otherwise the item is added to the session.

The item property can be used to retrieve the value of an item from the session state.

Common Properties & Methods of the HttpSessionState Class

Property Description
SessionID The unique ID of the session.
Item (name) The value of the session state item with the specified name.
Count The number of items in the session state
Method Description
Add (name, value) Adds an item to the session state collection.
Clear ( ) Removes all items from the session state collection.
Remove (name) Removes the item with the specified name from the session state collection.
Examples
'Statements that add or update a session state item

    Session("UserCart") = ShoppingCart
    Session.Add("UserCart", ShoppingCart)

'A statement that retrieves the value of a session state item

    Dim ShoppingCart As SortedList = CType(Session("UserCart"), SortedList)

'A statement that removes an item from session state
   
    Session.Remove("UserCart")

If you would like like to see a shopping cart in action, so you can see where we are headed with this, take a visit to:

Wal Mart Online → Store Pickup → Free Shipping
WM468X60_ko_static.gif

In order to continue with this guide, and start the discussion on Adding the Shopping Cart Class Press the Button below:


Visit Our Sponsor to Help Support Our Site - No Purchase Necessary


Home


Visual Basic

Introduction to VB.NET

.NET Framework

VS2008 IDE

How VB is Compiled

Start Visual Studio


Windows Form App


Save Your Work

VB OOP Programming

Visual Basic Code


Exit Code


Button Event Code

Coding Recommendations

If/Then/Else

Error List Window

Comment Syntax

Help Window

Language Essentianl

Built-In Data Types


Declare Variables

Declare Constants

Code Arithmetic Expressions

Assignment Statements

Operator Precedence

Type Casting


Math Class

String Declaration

Conversion Functions

Conversion Methods

Formatting Functions

String Formatting


Variable Scope

Enumerations

Nullable Types


Loop Constructs

For Next Loop

Do While Loop


Do Until Loop

Do...Loop-While

Do...Loop-Until


Exit Do | Exit For

Do...Loop


Nested Loops


Arrays

Array Declaration


Rnd( ) Function

Listbox Control


KeyPressEventArgs


Parallel Arrays

Key Event Args


Dynamic Arrays

Redimension Array

Set Breakpoint

Start Debugger


ReDim Preserve


MultiDimensional Arrays

DataGridView Control


Length and Sort Methods


Structures

Pad Right

Split Method

IsNumeric Function


Multiform Projects


Add Form To Project

Form Object Methods

Form Show Method

ShowDialog Method

Form Close Method

Form Accept Button

Multiform Project Example


ASP.NET Web Programming

Create Data Source


Configure Access Data Source


Add Product Class


Extract Local Database Data

Order PageLoad VB Code

Add New Web Page


Set Start Page

Display Cart Aspx Code

Display Cart Design View

Sorted List Definition

VB.NET Session State


Create CartItem Class

GetCartContents Function


Add To Cart Event Handler

Remove Cart Item Event


Clear Cart Event Handler


Can't open VisitorHistory.txt for reading