读书人

取出 dropdownlist 下拉框 内容解决方

发布时间: 2012-02-01 16:58:19 作者: rapoo

取出 dropdownlist 下拉框 内容
举例 :取出a,b等内容(内容是动态的)
<asp:DropDownList ID= "attachments " runat= "server ">
<asp:ListItem Value= "-1 " Selected= "True "> 附 件 清 单... </asp:ListItem>
<asp:ListItem> a </asp:ListItem>
<asp:ListItem> b </asp:ListItem>
</asp:DropDownList>

[解决办法]

Response.Write(attachments.SelectedItem.Text);

[解决办法]
在後台取如上的,
如果要在前台取js如下:

var attachments = document.getElementById( "attachments ");

var text = attachments.options[attachments.selectedIndex].text
[解决办法]

string mm = " ";
foreach(ListItem item in this.attachments.Items)
{
mm += item.Value;
}

return mm;

---------------------------------------------
EMail:bdbox@163.com 请给我一个与您交流的机会!

读书人网 >C#

热点推荐