questo è un esempio da adattare:
codice:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="a.aspx.vb" Inherits="prove_a" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="" EnableViewState="false"></asp:Label>
</div>
</form>
</body>
</html>
codice:
Option Strict On
Imports l = libreria.ModuloWeb
Partial Class prove_a
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
msole.FillListControl(Me.DropDownList1, New ListItem("", ""), New ListItem("text1", "value1"), New ListItem("text2", "value2"), New ListItem("text3", "value3"))
End If
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Dim dd As DropDownList = DirectCast(sender, DropDownList)
Me.Label1.Text = String.Format("Selected index: {0}, Selected value: {1}", dd.SelectedIndex, dd.SelectedValue)
End Sub
End Class