使用服务(内置)动态填充dropdownlist

来源:互联网 发布:移动网络下载不了电影 编辑:程序博客网 时间:2024/06/10 02:31
前台:<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;    }


0 0
原创粉丝点击