Torna al Thread
<%@ Page Language="C#" EnableViewState="true" %>
<%@ Import Namespace="System.Collections.Generic" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<int> lista = new List<int>();
for (int i = 0; i < 10; i++)
lista.Add(i);
listBox.DataSource = lista;
listBox.DataBind();
}
}
protected void listBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox.SelectedItem != null)
Response.Write("selezionato: " + listBox.SelectedItem.ToString());
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox ID="listBox" runat="server"
AutoPostBack="true"
onselectedindexchanged="listBox_SelectedIndexChanged"
Width="129px" Height="126px"></asp:ListBox>
</div>
</form>
</body>
</html>