获取前台select控件的值

heli_1005 2013-04-23 12:53:29
在前台写了: <select name="select" id="BD_year" runat="server" style="width:70px">
</select>

var i = 2010;
var dbYear = document.getElementById("BD_year");
var bdMonth = document.getElementById("BD_month");
var bdDay = document.getElementById("BD_day");
addListData(dbYear, "年")
addListData(bdDay, "月")
addListData(bdMonth, "日")

addDay(2010, 1997, dbYear);
addDay(12, 1, bdMonth);
addDay(31, 1, bdDay);


function addDay(max, min, obj) {

for (var i = max; i >= min; i--) {
addListData(obj, i)

}
}

function addListData(obj, i) {
var option = document.createElement("option");
option.text = i;
option.value = i;
try {
obj.add(option, null); // standards compliant
}
catch (ex) {
obj.add(option); // IE only
}
}




这是前台写的绑定<select>的值,我在后台怎么获取它的值呢
我试过:
string a = this.BD_year.DataTextField.ToString();
string b = this.BD_year.DataValueField.ToString();
string c = this.BD_year.SelectedIndex.ToString();
string ee = this.BD_year.Value.ToString();
string ccc= Request.Form["select2"].ToString();
这几个都获取不到值啊,应该怎么获取值呢?
...全文
145 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2013-04-24
  • 打赏
  • 举报
回复
使用ajax吧,好些。
Go 旅城通票 2013-04-23
  • 打赏
  • 举报
回复
你提交表单了没有?? string ccc= Request.Form["select2"].ToString(); 你名称改了没了?你原来的是select2,但是select的name值是select
heli_1005 2013-04-23
  • 打赏
  • 举报
回复
引用 1 楼 showbo 的回复:
C# code ? 1 string ccc= Request.Form["select"].ToString();//键名称写错了
这个没写错,有那个名为"select" 控件的。 只是也获取不到他的值
Go 旅城通票 2013-04-23
  • 打赏
  • 举报
回复
string ccc= Request.Form["select"].ToString();//键名称写错了

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧