ASP.NET DropDownListCheckBox使用示例(解決回發(fā)問題)
更新時(shí)間:2013年11月05日 16:25:39 作者:
本文為大家介紹下ASP.NET DropDownListCheckBox的使用,這個(gè)是根據(jù)LigerUI改的,解決了回發(fā)問題,喜歡的朋友可以參考下
這個(gè)是根據(jù)LigerUI改的,解決了回發(fā)問題
資料地址
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) {
//這個(gè)是用于在后臺(tái)獲取的
$("#HiddenField1").val(newvalue);
}
});
} else {
//解決回發(fā)問題
var data = eval('(' + $("#JSON").val() + ')');
manager = $("#test1").ligerComboBox({
isShowCheckBox: true, isMultiSelect: true,
data: data, valueFieldID: 'test3', onSelected: function (newvalue) {
//這個(gè)是用于在后臺(tái)獲取的
$("#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
{
//解決回發(fā)問題
context.Response.Write(select);
}
}
public bool IsReusable {
get {
return false;
}
}</p><p>}</p>
資料地址
http://ligerui.com/demos/comboBox/comboBoxMul.htm
具體代碼
復(fù)制代碼 代碼如下:
<%@ 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) {
//這個(gè)是用于在后臺(tái)獲取的
$("#HiddenField1").val(newvalue);
}
});
} else {
//解決回發(fā)問題
var data = eval('(' + $("#JSON").val() + ')');
manager = $("#test1").ligerComboBox({
isShowCheckBox: true, isMultiSelect: true,
data: data, valueFieldID: 'test3', onSelected: function (newvalue) {
//這個(gè)是用于在后臺(tái)獲取的
$("#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>
復(fù)制代碼 代碼如下:
<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>
復(fù)制代碼 代碼如下:
<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
{
//解決回發(fā)問題
context.Response.Write(select);
}
}
public bool IsReusable {
get {
return false;
}
}</p><p>}</p>
您可能感興趣的文章:
- ASP.NET DropDownList控件的使用方法
- asp.net省市三級(jí)聯(lián)動(dòng)的DropDownList+Ajax的三種框架(aspnet/Jquery/ExtJs)示例
- jquery獲取ASP.NET服務(wù)器端控件dropdownlist和radiobuttonlist生成客戶端HTML標(biāo)簽后的value和text值
- (asp.net c#)DropDownList綁定后顯示對(duì)應(yīng)的項(xiàng)的兩種方法
- asp.net DropDownList自定義控件,讓你的分類更清晰
- ASP.NET jQuery 實(shí)例7 通過jQuery來獲取DropDownList的Text/Value屬性值
- ASP.NET jQuery 實(shí)例8 (動(dòng)態(tài)添加內(nèi)容到DropDownList)
- ASP.NET jQuery 實(shí)例18 通過使用jQuery validation插件校驗(yàn)DropDownList
- asp.net中不能在DropDownList中選擇多個(gè)項(xiàng) 原因分析及解決方法
- asp.net中通過DropDownList的值去控制TextBox是否可編寫的實(shí)現(xiàn)代碼
- ASP.NET MVC DropDownList數(shù)據(jù)綁定及使用詳解
- ASP.NET筆記之 ListView 與 DropDownList的使用
- ASP.NET服務(wù)器端控件RadioButtonList,DropDownList,CheckBoxList的取值、賦值用法
- asp.net mvc下拉框Html.DropDownList 和DropDownListFor的常用方法
- ASP.NET MVC中為DropDownListFor設(shè)置選中項(xiàng)的方法
- ASP.NET中DropDownList和ListBox實(shí)現(xiàn)兩級(jí)聯(lián)動(dòng)功能
- asp.net DropDownList實(shí)現(xiàn)二級(jí)聯(lián)動(dòng)效果
- ASP.NET中DropDownList下拉框列表控件綁定數(shù)據(jù)的4種方法
相關(guān)文章
aspx實(shí)現(xiàn)的 jquery ui 的 flexgrid demo
這幾天沒事研究著jquery,真是個(gè)好東西,慢慢的知道了有jquery ui,一開始就被華麗的界面和簡單的操作給吸引了,尤其是里面的flexgrid,對(duì)我而言可以說是非常寶貴的東西2009-12-12
subsonic3.0插件更新字符串過長引發(fā)的異常修復(fù)方法
這篇文章主要介紹了subsonic3.0插件更新字符串過長引發(fā)的異常修復(fù)方法,需要的朋友可以參考下2014-04-04
Asp.Net防止刷新重復(fù)提交數(shù)據(jù)的辦法
最近在用Asp.Net編寫點(diǎn)東西時(shí)遇到個(gè)問題:即用戶在提交表單后按刷新就會(huì)重復(fù)提交數(shù)據(jù),即所謂的“刷新重復(fù)提交”的問題。2013-03-03
ASP.NET MVC:Filter和Action的執(zhí)行介紹
ASP.NET MVC之Filter和Action的執(zhí)行介紹,需要的朋友可以參考2012-11-11
ASP.NET MVC API 接口驗(yàn)證的示例代碼
本篇文章主要介紹了ASP.NET MVC API 接口驗(yàn)證的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-10-10
.Net使用RabbitMQ實(shí)現(xiàn)短信密碼重置的操作步驟
在C#開發(fā)中,通過RabbitMQ實(shí)現(xiàn)短信服務(wù)可增強(qiáng)應(yīng)用的消息通知能力,本文介紹了使用RabbitMQ發(fā)送短信的步驟,包括安裝RabbitMQ客戶端庫、創(chuàng)建連接和通道、實(shí)現(xiàn)短信發(fā)送服務(wù)、配置RabbitMQ消費(fèi)者,并集成到用戶密碼重置流程中,通過示例代碼,可以快速理解整個(gè)實(shí)現(xiàn)過程2024-09-09
asp.net中頁面顯示當(dāng)前系統(tǒng)時(shí)間附圖
asp.net如何實(shí)現(xiàn)在頁面顯示當(dāng)前系統(tǒng)時(shí)間,本文有個(gè)不錯(cuò)的方法,大家可以嘗試操作下,在文章末尾有截圖2013-12-12

