zoukankan      html  css  js  c++  java
  • DevExtreme 学习应用[2]

    DevExtreme 学习应用[2]

    调用WebService数据

    1那么首先建立WebService

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    namespace WebService
    {
        /// <summary>
        /// WebService 的摘要说明
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        [System.Web.Script.Services.ScriptService]
        //以上这句要有 不然会报错  因为手机开发一般是要以Json形式获取数据
    public class WebService : System.Web.Services.WebService
        {
    
            [WebMethod]
            public string HelloWorld()
            {
                return "Hello World";
            }
        }
    }

    2HTML

      <div data-bind="dxCommand: {
    title: 'Search', placeholder: 'Search...',
        location: 'create', icon: 'btn',value:'button', action: find
    }"></div>

    3JavaScript  该JS是以Jquery的形式调用的。所以只要做过Jquery的都比较清楚

    Application1.ProductDetial = function (params) {
    
        var viewModel = {
            find: function () {
                $.ajax({
                    url: 'http://localhost:5421/WebService/WebService.asmx/HelloWorld',
                    data: {},
                    //data:{} 因为我们在这里测试的使用的HelloWord 方法是无参的。所以这里为空。要是有参数的方法  如参数为Name:data:{name:'李四'}  备注:这里的参数名 最好和服务端的参数名称一致
    contentType:
    "application/json", dataType: "json", type: "POST", success: function (result) { alert(result.d); }, error: function (xml, status) { alert(status); } }); } }; return viewModel; };

     总结:DevExtreme 开发中调试通了 调用C# WebService的方法。

  • 相关阅读:
    Named Formats!
    基于vue的自定义日历组件
    vue使用html2canvas实现移动端H5页面截图
    vue使用domtoimage实现移动端H5页面截图
    swiper5切换页面数据动态加载
    H5 jq+canvas实现pc写字板功能
    vue多语言转换的几种方法
    echarts折线图单组数据配置
    H5 canvas的使用(二):移动端手势密码
    svn的仓库设置钩子自动更新
  • 原文地址:https://www.cnblogs.com/w2011/p/3423219.html
Copyright © 2011-2022 走看看