当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET DropDownListCheckBox使用示例(解决回发问题)

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

9c8869,火影之不死邪帝,武汉枪击案

这个是根据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))
{
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>

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网