⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listitemcollection.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<Script Runat="Server">

Sub lstProducts_SelectedIndexChanged( s As Object, e As EventArgs )
  lstCart.SelectedIndex = -1
  lstCart.Items.Add( lstProducts.SelectedItem )
End Sub

Sub btnRemove_Click( s As Object, e As EventArgs )
  lstCart.Items.Remove( lstCart.SelectedItem )
End Sub

Sub btnRemoveAll_Click( s As Object, e As EventArgs )
  lstCart.Items.Clear()
End Sub

</Script>

<html>
<head><title>ListItemCollection.aspx</title></head>
<body>

<form Runat="Server">

<h2>Products:</h2>
<asp:ListBox
  id="lstProducts"
  Width="200"
  AutoPostBack="True"
  OnSelectedIndexChanged="lstProducts_SelectedIndexChanged"
  Runat="Server">
  <asp:ListItem Text="Hair Dryer"/>
  <asp:ListItem Text="Shaving Cream"/>
  <asp:ListItem Text="Electric Comb"/>
  <asp:ListItem Text="Nail Polish"/>
  <asp:ListItem Text="French Toast"/>
</asp:ListBox>

<p>

<h2>Shopping Cart:</h2>
<asp:ListBox
  ID="lstCart"
  Width="200"
  Runat="Server"/>
<br>
<asp:Button
  id="btnRemove"
  Text="Remove Item"
  OnClick="btnRemove_Click"
  Runat="Server"/>

<asp:Button
  id="btnRemoveAll"
  Text="Remove All"
  OnClick="btnRemoveAll_Click"
  Runat="Server"/>

</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -