Hot-Link Menu in Right-Side Column

Wal Mart Online → Store Pickup → Free Shipping

Event Handler Code for Empty Cart Button

The next button on the DisplayCart.aspx we will deal with is the EmptyCart button. Pressing this button will both clear the CartContents from Session State, and clear the lstCart Listbox, indicating that all items have been deleted. Double-Click the Empty Cart button in Design View and enter the following code:

    'Event Handler for Empty Shopping Cart
    Protected Sub btnEmpty_Click(ByVal sender As Object, _
        ByVal e As EventArgs) Handles btnEmpty.Click

        'If the Cart isn't already empty:
        If CartContents.Count > 0 Then

            'Clear Session State & ListBox
        End If

    End Sub

Run the program and add your favorite items. You can stop at 2 or 3, there probably isn't any point in going past 5 or 10. Press the Empty Button to make sure the ListBox clears. If it doesn't cut and paste the code above, and try again. Make sure the program is running smoothly before proceeding to the next step.

Buy from Centurion

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

Excellent Tech Support - Centurion Approved

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

In order to continue with this guide, and begin the discussion on Emptying The Shopping Cart Press the Button below:

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


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


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


Nullable Types

Loop Constructs

For Next Loop

Do While Loop

Do Until Loop



Exit Do | Exit For


Nested Loops


Array Declaration

Rnd( ) Function

Listbox Control


Parallel Arrays

Key Event Args

Dynamic Arrays

Redimension Array

Set Breakpoint

Start Debugger

ReDim Preserve

MultiDimensional Arrays

DataGridView Control

Length and Sort Methods


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