源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

ASP.NET DropDownListCheckBox使用示例(解决回发问题)

  • 时间:2022-07-30 17:40 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:ASP.NET DropDownListCheckBox使用示例(解决回发问题)
这个是根据LigerUI改的,解决了回发问题 [img]http://files.jb51.net/file_images/article/201311/20131105162323.jpeg?201310516246[/img]   资料地址 http://ligerui.com/demos/comboBox/comboBoxMul.htm 具体代码
[url=lib/ligerUI/skins/Aqua/css/ligerui-all.css]<script src="lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="lib/ligerUI/js/core/base.js" type="text/javascript"></script> <script src="lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script> <script src="lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script> <script src="lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var manager; $.get("CheckBoxHandle.ashx?tem=" + Math.random() + "&selectValue=" + $("#HiddenField1").val(), function (value) { if (value.lastIndexOf("[") >= 0) { $("#JSON").val(value); var data = eval('(' + value + ')'); manager = $("#test1").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true, data: data, valueFieldID: 'test3', onSelected: function (newvalue) { //这个是用于在后台获取的 $("#HiddenField1").val(newvalue); } }); } else { //解决回发问题 var data = eval('(' + $("#JSON").val() + ')'); manager = $("#test1").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true, data: data, valueFieldID: 'test3', onSelected: function (newvalue) { //这个是用于在后台获取的 $("#HiddenField1").val(newvalue); } }); manager.selectValue(value); } }); }); function clickee() { alert($("#test3").val()); } </script> </head> <body> <form id="form1" runat="server"> <div> <input type="text" id="test1" /> <asp:HiddenField ID="HiddenField1" ClientIDMode="Static" runat="server" /> <asp:HiddenField ID="JSON" ClientIDMode="Static" runat="server" /> <asp:Button ID="Button1" OnClick="Button1_Click" OnClientClick="clickee();" runat="server" Text="获取" /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form> </body> </html>
[u]复制代码[/u] 代码如下:
<p><%@ WebHandler Language="C#" Class="CheckBoxHandle" %></p><p>using System; using System.Web; using System.Collections.Generic;</p><p>public class CheckBoxHandle : IHttpHandler { public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; string select = context.Request.QueryString["selectValue"].ToString(); if (string.IsNullOrEmpty(select)) { List<Type> list = new List<Type>(); list.Add(new Type { ID = 1, Name = "SAm" }); list.Add(new Type { ID = 2, Name = "Tom" }); list.Add(new Type { ID = 3, Name = "jim" }); context.Response.Write(JsonHelper.GetJSONString(list)); } else { //解决回发问题 context.Response.Write(select); } } public bool IsReusable { get { return false; } }</p><p>}</p>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部