这个是根据LigerUI改的,解决了回发问题
资料地址
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))
{
ListType> list = new ListType>();
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 DropDownList控件的使用方法
- asp.net省市三级联动的DropDownList+Ajax的三种框架(aspnet/Jquery/ExtJs)示例
- jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist生成客户端HTML标签后的value和text值
- (asp.net c#)DropDownList绑定后显示对应的项的两种方法
- asp.net DropDownList自定义控件,让你的分类更清晰
- ASP.NET jQuery 实例7 通过jQuery来获取DropDownList的Text/Value属性值
- ASP.NET jQuery 实例8 (动态添加内容到DropDownList)
- ASP.NET jQuery 实例18 通过使用jQuery validation插件校验DropDownList
- asp.net中不能在DropDownList中选择多个项 原因分析及解决方法
- asp.net中通过DropDownList的值去控制TextBox是否可编写的实现代码
- ASP.NET MVC DropDownList数据绑定及使用详解
- ASP.NET笔记之 ListView 与 DropDownList的使用
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- asp.net mvc下拉框Html.DropDownList 和DropDownListFor的常用方法
- ASP.NET MVC中为DropDownListFor设置选中项的方法
- ASP.NET中DropDownList和ListBox实现两级联动功能
- asp.net DropDownList实现二级联动效果
- ASP.NET中DropDownList下拉框列表控件绑定数据的4种方法