ASP.NET DropDownListCheckBox使用示例(解决回发问题)
2013-11-05 00:00
786 查看
这个是根据LigerUI改的,解决了回发问题
资料地址 http://ligerui.com/demos/comboBox/comboBoxMul.htm
具体代码
资料地址 http://ligerui.com/demos/comboBox/comboBoxMul.htm
具体代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckBoxList.aspx.cs" Inherits="CheckBoxList" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/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>
<p>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;</p><p>public partial class CheckBoxList : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {</p><p> } protected void Button1_Click(object sender, EventArgs e) { this.Label1.Text = this.HiddenField1.Value; } }</p>
<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>
相关文章推荐
- ASP.NET DropDownListCheckBox使用示例(解决回发问题)
- ASP.NET DEMO 14: 如何在 GridView/DataGrid 模板列中使用自动回发的 CheckBox/DropDownList
- ASP.NET DEMO 14: 如何在 GridView/DataGrid 模板列中使用自动回发的 CheckBox/DropDownList
- asp.net中回发或回调参数无效。在配置中使用 <pages enableEventValidation="... 问题解决
- ASP.NET 4.0中使用FCKeditor遇到安全问题警告的解决办法
- 使用javaScript解决asp.net中mvc使用ajax提交数组参数的匹配问题
- Asp.net生成l文件并下载-----解决使用迅雷下载页面而不是文件的问题
- 使用JavaScript脚本无法直接改变Asp.net中Checkbox控件的Enable属性的解决方法
- asp.net 使用Ueditor过程中出现的问题及解决办法
- 使用Newtonsoft.json 解决 Asp.Net MVC DateTime类型数据Json格式化问题
- asp.net c#的传参中经常使用到中文参数的处理,下面的函数可以解决中文参数的问题
- Asp.net MVC 3 Razor 视图引擎 中使用@输出的内容都会被自动进行HTML编码 问题的解决办法
- ASP.NET 4.0中使用FreeTextBox和FCKeditor遇到安全问题警告的解决办法
- 使用javaScript解决asp.net中mvc使用ajax提交数组参数的匹配问题
- 【原】Asp.net生成Excel文件并下载(更新:解决使用迅雷下载页面而不是文件的问题)
- ASP.NET DEMO 14: 如何在 GridView/DataGrid 模板列中使用自动回发的 CheckBox/DropDownList
- 黑马程序员之ASP.NET学习笔记:AJAX解决什么问题?如何使用AJAX?
- asp.net 数据绑定 使用eval 时候报 字符文本中的字符太多 问题的解决方法