日期:2014-05-19  浏览次数:20686 次

C#能否读取客户端控件(多选下拉列表)的value?------在线等待
C#能否读取客户端控件(多选下拉列表)的value?
------------------------------------------------
<select   name= "myarea "   id= "myarea "   multiple= "multiple ">
    <option   value= "1 "> aa </option>
    <option   value= "2 "> bb </option>
    <option   value= "3 "> cc </option>
</select>
------------------------------------------------
用Request.Form[ "AskPosition2 "]读不到任何值


------解决方案--------------------
try

Request[ "myarea "]
------解决方案--------------------
Request[ "myarea "]
------解决方案--------------------
检查一下该控件是否在 form 标签中。
------解决方案--------------------
如果不选中myarea中的选项怎么能取到选项中的所有值?
----------------
没有办法
------解决方案--------------------
如果不选中myarea中的选项怎么能取到选项中的所有值?
提交时使用脚本遍历

var s = " "
for(i = 0;i <document.getElementById( "myarea ").options.length;i++)
s+=document.getElementById( "myarea ").options[i].value + ", "

document.getElementById( "x ").value=s

<input id=x name=x type=hidden>

服务器端取
Request[ "x "]
------解决方案--------------------
function smit()
{
var s = " "
for(i = 0;i <document.getElementById( "myarea ").options.length;i++)
s+=document.getElementById( "myarea ").options[i].value + ", "

document.getElementById( "x ").value=s

}


<input id=x name=x type=hidden>
<input type=submit onclick= "smit() ">