主题:大家帮我试试.看看.
.aspx ------->>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!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:ListBox ID="ListBox1" runat="server" Width="404px"></asp:ListBox>
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
.vb --------->>
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.ListBox1.Items.Clear()
Dim listItems(0 To 2) As ListItem
listItems(0) = New ListItem("feifei", 0)
listItems(1) = New ListItem("sunny", 1)
listItems(2) = New ListItem("taiya", 2)
Me.ListBox1.Items.AddRange(listItems)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each li As ListItem In Me.ListBox1.Items
Response.Write(li.ToString() + ":" + li.Selected.ToString() + "<br/>")
Next
End Sub
End Class
代码是我简化出来的.为什么选定项,在显示中总是显示false.即列表框选择不了.EnableViewState属性没问题.AutoPostBack在这里属性绝对不能设为ture的.该不会是我机子的问题.帮忙看看,试试.谢谢 [em2][em1]
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!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:ListBox ID="ListBox1" runat="server" Width="404px"></asp:ListBox>
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
.vb --------->>
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.ListBox1.Items.Clear()
Dim listItems(0 To 2) As ListItem
listItems(0) = New ListItem("feifei", 0)
listItems(1) = New ListItem("sunny", 1)
listItems(2) = New ListItem("taiya", 2)
Me.ListBox1.Items.AddRange(listItems)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each li As ListItem In Me.ListBox1.Items
Response.Write(li.ToString() + ":" + li.Selected.ToString() + "<br/>")
Next
End Sub
End Class
代码是我简化出来的.为什么选定项,在显示中总是显示false.即列表框选择不了.EnableViewState属性没问题.AutoPostBack在这里属性绝对不能设为ture的.该不会是我机子的问题.帮忙看看,试试.谢谢 [em2][em1]