Figure 337 Html Selectlaspx

<%@ page language="VB" debug="true" %>

<html><head></head><form runat="server">

<select id= "lstFlowers" size="3" runat="server" /><br/><br/> <input id="btnSubmit" type="button" runat="server" value="Submit"

onServerClick="showSelection"><br/><br/> <span id=spnMessage runat="server"/><br> <span id=spnPrice runat="server"/><br> </form></html>

<script language="VB" runat="server">

Sub Page_Load(source As Object, e As EventArgs)

If Not IsPostBack Then

Dim sortedList1 As New SortedList() ' Load the SortedList object sortedList1.Add("Tulip", 10.7 5) sortedList1.Add("Poppy",2 0.22) sortedList1.Add("Azalea",30.33) Dim i As Integer

' Bind the HtmlSelect control (list box) with the key values ' of the SortedList object lstFlowers.DataSource=sortedList1.Keys lstFlowers.DataBind()

Session.Timeout=10 'Set the session timeout to 10 minutes ' Save the populated SortedList in the session Session("savedList")=sortedList1 End If End Sub

Sub showSelection(sender As Object, e As EventArgs) Dim sortedList1 As New SortedList()

' Load the Session's savedList into an instance of a SortedList


Figure 3.37 Continued sortedList1=Session("savedList")

Dim i As Integer Dim msg As String Dim dblPrice as Double dblPrice=sortedList1.GetValueList(lstFlowers.SelectedIndex) spnMessage.InnerHtml="You have selected " + lstFlowers.Value spnPrice.InnerHtml="Its price is: " + FormatCurrency(dblPrice) End Sub </script>

0 0

Post a comment