获取前台select控件的值
在前台写了: <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();
这几个都获取不到值啊,应该怎么获取值呢?
------解决方案--------------------string ccc= Request.Form["select"].ToString();//键名称写错了
------解决方案--------------------使用ajax吧,好些。