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

📄 dropdownlistvalueselected.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Page Language="C#"%>

<script runat=server>

void Button_Click(Object sender , EventArgs e) 
{
  lblSelectedIndex.Text = dropCategory.SelectedIndex.ToString();
  lblSelectedText.Text = dropCategory.SelectedItem.Text.ToString();
  lblSelectedValue.Text = dropCategory.SelectedItem.Value.ToString();
}

</Script>

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

<form Runat="Server">

<asp:DropDownList
  ID="dropCategory"
  Runat="Server">
  <asp:ListItem
    Text="Country Music"
    Value="country" />
  <asp:ListItem
    Text="Rock Music"
    Value="rock"
    Selected="True"/>
  <asp:ListItem
    Text="Classical Music"
    Value="classic" />
</asp:DropDownList>

<asp:Button
  Text="Select Category!"
  OnClick="Button_Click"
  Runat="Server" />

<hr>

Selected Index:
<asp:Label
  ID="lblSelectedIndex"
  Runat="Server" />

<p>
Selected Text:

<asp:Label
  ID="lblSelectedText"
  Runat="Server" />

<p>
Selected Value:
<asp:Label
  ID="lblSelectedValue"
  Runat="Server" />

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

⌨️ 快捷键说明

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