国内大型网站域名,seo技巧seo排名优化,校园网页设计代码,微信ios分身版下载花了近一天的时间调试解决#xff0c;希望对有相同需要的朋友有帮助#xff1a;1、新建一空网站,添加一个web页面webform1.aspx#xff0c;添加ExtJs相关引用link hrefExtJs4.0.7/resources/css/ext-all.cssrelstylesheettypetext/css希望对有相同需要的朋友有帮助1、新建一空网站,添加一个web页面webform1.aspx添加ExtJs相关引用 link hrefExtJs4.0.7/resources/css/ext-all.css relstylesheet typetext/css / script srcExtJs4.0.7/bootstrap.js typetext/javascript/script2、添加一个启用AJAX的WCF服务Service1.svc如下图3、修改web.config文件将enableWebScript /注释掉换成webHttp /这一步很关键 system.serviceModel behaviors endpointBehaviors behavior nameWcfAjaxDemo.Service1AspNetAjaxBehavior !--enableWebScript /-- webHttp / /behavior /endpointBehaviors /behaviors serviceHostingEnvironment aspNetCompatibilityEnabledtrue multipleSiteBindingsEnabledtrue / services service nameWcfAjaxDemo.Service1 endpoint address behaviorConfigurationWcfAjaxDemo.Service1AspNetAjaxBehavior bindingwebHttpBinding contractWcfAjaxDemo.Service1 / /service /services /system.serviceModel4、WCF中的方法前加上[WebGet(RequestFormat WebMessageFormat.Xml, ResponseFormat WebMessageFormat.Json)]这一步也很关键如下[DataContract] public class treenode { [DataMember] public string id; [DataMember] public string text; [DataMember] public Listtreenode children new Listtreenode(); [DataMember] public string cls; [DataMember] public bool leaf; } [ServiceContract(Namespace WcfAjaxDemo)] [AspNetCompatibilityRequirements(RequirementsMode AspNetCompatibilityRequirementsMode.Allowed)] public class Service1 { // 要使用 HTTP GET请添加 [WebGet] 特性。(默认 ResponseFormat 为 WebMessageFormat.Json) // 要创建返回 XML 的操作 // 请添加 [WebGet(ResponseFormatWebMessageFormat.Xml)] // 并在操作正文中包括以下行: // WebOperationContext.Current.OutgoingResponse.ContentType text/xml; [OperationContract] [WebGet(RequestFormat WebMessageFormat.Xml, ResponseFormat WebMessageFormat.Json)] public treenode[] GetTree() { // 在此处添加操作实现 treenode t new treenode(); t.id noe1; t.text 节点1; t.cls folder; treenode t0 new treenode(); t0.id noe1_0; t0.text 节点1_0; t0.cls folder; t0.leaf true; t.children.Add(t0); treenode t1 new treenode(); t1.cls folder; t1.id 000; t1.text 节点1; treenode t2 new treenode(); t2.id noe1_1; t2.text 节点1_1; t2.cls folder; t2.leaf true; t1.children.Add(t2); Listtreenode nodes new Listtreenode(); nodes.Add(t); nodes.Add(t1); return nodes.ToArray(); } // 在此处添加更多操作并使用 [OperationContract] 标记它们 } 在IE地址栏里输入http://localhost:18564/Service1.svc/GetTree测试WCF是否正常正常会提示文件下载用记事本打开后显示如下[{children:[{children:[],cls:folder,id:noe1_0,leaf:true,text:节点1_0}],cls:folder,id:noe1,leaf:false,text:节点1},{children:[{children:[],cls:folder,id:noe1_1,leaf:true,text:节点1_1}],cls:folder,id:000,leaf:false,text:节点1}] 如果不正常会出现如下提示请检查第3、4步5、客户端使用ExtJs调用生成树TreePanel% Page LanguageC# AutoEventWireuptrue CodeBehindWebForm1.aspx.cs InheritsWcfAjaxDemo.WebForm1 %!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhtml xmlnshttp://www.w3.org/1999/xhtmlhead runatserver title/title link hrefExtJs4.0.7/resources/css/ext-all.css relstylesheet typetext/css / script srcExtJs4.0.7/bootstrap.js typetext/javascript/script script typetext/jscript Ext.require([*]); Ext.onReady(function () { var store Ext.create(Ext.data.TreeStore, { proxy: { type: ajax, url: Service1.svc/GetTree }, root: { text: Ext JS, id: src, expanded: true }, folderSort: true, sorters: [{ property: text, direction: ASC }] }); var tree Ext.create(Ext.tree.Panel, { id: tree, store: store, width: 250, height: 300, viewConfig: { plugins: { ptype: treeviewdragdrop, appendOnly: true } }, renderTo: document.body }); }); /script/headbody form idform1 runatserver /form/body/html 6、运行webform1.aspx如下图转载于:https://www.cnblogs.com/suncarry/archive/2012/02/02/2335983.html