前台:
<head runat="server">
<title></title>
<script type="text/javascript">
function SetImageList(obj) {
PageMethods.ImagePathList(obj.id,SucFun,ErrFun);
}
function SucFun(res) {
var id=res[res.length-1];
var obj = document.getElementById(id);
for (var i = 0; i < res.length-1; i++) {
var varItem = new Option(res[i], res[i]);
obj.options.add(varItem);
}
obj.onclick = "";
}
function ErrFun(err) {
}
function AddDropDownClick(obj ) {
obj.onclick = SucFun(obj);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</div>
</form>
</body>
后台:
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static List<string> ImagePathList(string drodownid) {
List<string> listtemp = new List<string>();
listtemp.Add("aa");
listtemp.Add("bb");
listtemp.Add(drodownid);
return listtemp;
}