读书人

服务器端控件跟客户端控件的综合应用

发布时间: 2011-12-15 23:41:24 作者: rapoo

服务器端控件和客户端控件的综合应用
我的页面上有一个服务器端控件dropDownList,一个客户端控件selectedList.

我怎样能在客户端取得服务器端控件dropDownList的值,并传递给另一个页面。


[解决办法]
服务器端控件生成的html代码的id是一样的(除了DataGrid那样的),可以用getElementById试试
[解决办法]
在客户端取得服务器端控件dropDownList的值

这个js不就可以吗?getElementById 对的阿,或者看看Clientid
[解决办法]
document.getElementById(“DropDownList1”);
[解决办法]
var vl=aaa.options[0].value;
alert(vl);
[解决办法]
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default2.aspx.cs " Inherits= "Default2 " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<script language= "javascript ">
function Button1_onclick()
{
var aaa= document.getElementById( 'DropDownList1 ');
alert(aaa);
}

</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<asp:DropDownList ID= "DropDownList1 " runat= "server ">
<asp:ListItem> sdfdsfd </asp:ListItem>
<asp:ListItem> dsfacvxz </asp:ListItem>
<asp:ListItem> dfsacvxv </asp:ListItem>
<asp:ListItem> dfscxvcvx </asp:ListItem>
<asp:ListItem> dfdcvxvczxv </asp:ListItem>
<asp:ListItem> dferervccvvc </asp:ListItem>
</asp:DropDownList>
<input id= "dd " type= "button " onclick= "Button1_onclick(); " />


</form>
</body>
</html>

[解决办法]
document.getElementById(“DropDownList1”);
var vl=aaa.options[0].value;
alert(vl);

[解决办法]
options[aaa.selectedIndex].value;是选中值的value

读书人网 >asp.net

热点推荐