<script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script>
<link type="text/css" rel="Stylesheet" href="jquery-easyui-1.6.11/themes/default/easyui.css" />
<link type="text/css" rel="Stylesheet" href="jquery-easyui-1.6.11/themes/icon.css" />
<script type="text/javascript" src="jquery-easyui-1.6.11/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui-1.6.11/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function () { $.ajax({
type: "Post",
url: "easyuiComboBox.aspx/GetBrowser",
// data: "{}",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function (data) { $('#first_catalogue').combobox({
data: eval(data.d), //eval(data.d)将JSON的字符串解析成JSON数据格式
valueField: 'value',
textField: 'text',
groupField: 'group',
required: true,
editable: false,
onLoadSuccess: function () {
//加载完成后,设置选中第一项
var val = $(this).combobox("getData");
//设置第一个值为选中值
$(this).combobox("select", val[0].text);
},
onChange: function () { //getValue,getText分别获取value值,text
var val = $('#first_catalogue').combobox("getText"); alert(val);
}
}); },
error: function (err) {
alert(JSON.parse(err.responseText).Message);
}
}); });
</script>

html

 <input class="easyui-combobox" id="first_catalogue" style="width: 30%;" value="--请选择所属分类--">

后台代码

        [WebMethod]
public static string GetBrowser()
{
string json = "[{\"value\":\"f20\",\"text\":\"Firefox 2.0 or higher\",\"group\":\"Firefox\"}" +
",{\"value\":\"f15\",\"text\":\"Firefox 1.5.x\",\"group\":\"Firefox\"}," +
"{\"value\":\"f10\",\"text\":\"Firefox 1.0.x\",\"group\":\"Firefox\"}," +
"{\"value\":\"ie7\",\"text\":\"Microsoft Internet Explorer 7.0 or higher\",\"group\":\"Microsoft Internet Explorer\"}" +
",{\"value\":\"ie6\",\"text\":\"Microsoft Internet Explorer 6.x\",\"group\":\"Microsoft Internet Explorer\"}]";
return json; //List<Browser> browsers=new List<Browser>();
//Browser b= new Browser();
//b.value ="f20";
//b.text ="Firefox 2.0 or higher";
//b.group="Firefox";
//browsers.Add(b);
//JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
//return jsSerializer.Serialize(browsers);
}

显示效果

easyui combobox 动态加载数据C#的更多相关文章

  1. easyui combobox 动态加载数组数据

    怕自己忘了,记录下来以后用方便 html部分 <input id="rzcode" name="businesItemId" style="wi ...

  2. easyui datagrid 动态加载数据 渲染问题,表格错位问题

    $('#dg').datagrid({ url:'datagrid_data.json', columns:[[ {field:'code',title:'Code',width:100}, {fie ...

  3. easyui combobox 动态加载的两种方法

    reload 方法 javascript代码 //指定id 和 text 否则始终选择第一个 $('#contact_city').combobox({ valueField:'id', textFi ...

  4. extjs Combobox动态加载数据问题,mode:local 还是remote

    var fabircTypeDs = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: 'province.do' }), reade ...

  5. 42.extjs Combobox动态加载数据问题,mode:local 还是remote

    问题: Java代码   var fabircTypeDs = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: 'province. ...

  6. Easyui combobox 怎么加载数据

    说明:开发环境 vs2012 asp.net mvc4 c# 1.效果图 2.HTML代码 <%@ Page Language="C#" AutoEventWireup=&q ...

  7. AppCan学习笔记----关闭页面listview动态加载数据

    AppCan页面关闭 AppCan 的页面是由两个HTML组成,如果要完全关闭的话需要在主HTML eg.index.html中关闭,关闭方法:appcan.window.close(-1); 管道 ...

  8. [JS前端开发] js/jquery控制页面动态加载数据 滑动滚动条自动加载事件

    页面滚动动态加载数据,页面下拉自动加载内容 相信很多人都见过瀑布流图片布局,那些图片是动态加载出来的,效果很好,对服务器的压力相对来说也小了很多 有手机的相信都见过这样的效果:进入qq空间,向下拉动空 ...

  9. 微信小程序(五) 利用模板动态加载数据

    利用模板动态加载数据,其实是对上一节静态数据替换成动态数据:

随机推荐

  1. day9 九、函数

    一.函数 1.函数:可以完成特定功能的代码块,函数就是存放代码块的容器 2.定义函数的语法: 函数四部分:(函数执行的本质:执行函数体,得到函数返回值) ①函数名 ②函数体 ③返回值 ④参数 用def ...

  2. 具有键“XXX”的 ViewData 项属于类型“System.Int32”,但它必须属于类型“IEnumerable<SelectListItem>

    原因是Edit视图中有@Html.DropDownListFor(m => m.BirthdayAD... 但是没有从Controller中没有设置值

  3. org.apache.jasper.JasperException:Unable to read TLD "META-INF/c-1_0-rt.tld" from JAR file jstl-1.2.jar

    前两天把项目从eclipse EE版搬到MyEclipse中了.配置好jdk,确定build path中没有报错后,在tomcat中运行.结果,报错: org.apache.jasper.Jasper ...

  4. 对Entity Framework Core的一次误会:实体状态不跟踪

    在 Entity Framework 中,当通过 EF 使用 LINQ 查询获取到一个实体(实际得到的是 EF 动态生成的实体类的代理类的实例)时,这个实体的状态默认是被跟踪的.所以,当你修改实体的某 ...

  5. 《开源网店系统iWebShop2.0模板开发教程》的说明

    <开源网店系统iWebShop2.0模板开发教程>是网上广为流传的一个文档,有点问题. 其中的第4章: ========================================== ...

  6. arcengine新建要素类

    ArcGIS里面新建数据集,看起来简单,平时都是默认创建,实际上好多细节问题我们都没注意到 一.在数据集上新建要素类: How to create a feature class within a f ...

  7. spark Pair RDD 基础操作

    下面是Pair RDD的API讲解 转化操作 reduceByKey:合并具有相同键的值: groupByKey:对具有相同键的值进行分组: keys:返回一个仅包含键值的RDD: values:返回 ...

  8. Apache SSL 服务搭建

    Web服务器在默认情况下使用HTTP,这是一个纯文本的协议.正如其名称所暗示的,纯文本协议不会对传输中的数据进行任何形式的加密.而基于HTTP的Web服务器是非常容易配置,它在安全方面有重大缺陷.任何 ...

  9. VSCode代码修改后跑起来没反应,打开本地文件,代码没变化

    两种解决办法: 首先:修改VSCode默认配置文件,点击左下角设置标志图 -> 设置,出来了设置相关的东西,搜索 files.autoSave 第一种:把"files.autoSave ...

  10. R的常用命令

    mean(x) 求x的均值 sd(x) 求x的标准差 plot(x,y) 图形展示x和y的关系 ls() 查看当前所有加载到内存中的对象 rm(x) 删除当前内存中的对象x length(x) 求x的 ...