asp.net dropdownlistcheckbox Use example (solve postback problem) _ Practical Tips

Source: Internet
Author: User
This is changed according to Ligerui, solve the problem of postback

Data address
Http://ligerui.com/demos/comboBox/comboBoxMul.htm
Specific code
Copy Code code as follows:

<%@ Page language= "C #" autoeventwireup= "true" codefile= "CheckBoxList.aspx.cs" inherits= "CheckBoxList"%>
<! DOCTYPE html>
<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) {
This is used in the background to get the
$ ("#HiddenField1"). Val (NewValue);
}
});
} else {
Resolve postback problem
var data = eval (' + $ (' #JSON '). Val () + ') ');
Manager = $ ("#test1"). Ligercombobox ({
Isshowcheckbox:true, Ismultiselect:true,
Data:data, Valuefieldid: ' Test3 ', onselected:function (newvalue) {
This is used in the background to get the
$ ("#HiddenField1"). Val (NewValue);
}
});
Manager.selectvalue (value);
}
});
});
function Clickee () {
Alert ($ ("#test3"). Val ());
}
</script>

<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=" get "/>
<asp:label id= "Label1" runat= "Server" text= "Label" ></asp:Label>
</div>
</form>
</body>


Copy Code code as follows:

<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>

Copy Code code as follows:

<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 Pr Ocessrequest (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
{
/Resolve postback issue
context. Response.Write (select);
}
}
public bool IsReusable {
Get {
] false;
}
}</p><p>}</p>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.