📄 checkboxlistvalueselected.aspx
字号:
<%@ Page Language="C#"%>
<script runat=server>
void Button_Click(Object sender , EventArgs e)
{
string strTextList = String.Empty, strValueList = String.Empty;
foreach (ListItem itmProduct in chklProducts.Items)
if ( itmProduct.Selected )
{
strTextList += "<li>" + itmProduct.Text;
strValueList += "<li>" + itmProduct.Value;
lblSelectedText.Text = strTextList.ToString();
lblSelectedValue.Text = strValueList.ToString();
}
}
</Script>
<html>
<head><title>CheckBoxListValueSelected.aspx</title></head>
<body>
<form Runat="Server">
<asp:CheckBoxList
id="chklProducts"
Runat="Server">
<asp:ListItem
Text="Hair Dryer"
Value="A8999" />
<asp:ListItem
Text="Shaving Cream"
Value="S7777"
Selected="True"/>
<asp:ListItem
Text="Electric Comb"
Value="E23234" />
</asp:CheckBoxList>
<p>
<asp:Button
Text="Select Products!"
OnClick="Button_Click"
Runat="Server" />
<hr>
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 + -