zoukankan      html  css  js  c++  java
  • csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C#.

     /// <summary>
        ///參考: http://james.newtonking.com/json/help/index.html#
        /// 塗聚文(Geovin Du) 20141228
        /// 捷為工作室
        /// </summary>
        public partial class _Default : System.Web.UI.Page
        {
            Geovindu_TimeLineProjectInfo geovindu_TimeLineProjectInfo = new Geovindu_TimeLineProjectInfo();
            Geovindu_TimeLineProjectBLL geovindu_TimeLineProjectBLL = new Geovindu_TimeLineProjectBLL();
            Geovindu_TimeLineAssetInfo geovindu_TimeLineAssetProjectInfo = new Geovindu_TimeLineAssetInfo();
    
            List<Geovindu_TimeLineDataInfo> selectGeovindu_TimeLineDataProject = new List<Geovindu_TimeLineDataInfo>();
    
            Geovindu_TimeLineDataInfo geovindu_TimeLineDataInfo = new Geovindu_TimeLineDataInfo();
            Geovindu_TimeLineAssetInfo geovindu_TimeLineAssetDataInfo = new Geovindu_TimeLineAssetInfo();
    
            Geovindu_TimeLineAssetBLL geovindu_TimeLineAssetBLL = new Geovindu_TimeLineAssetBLL();
            Geovindu_TimeLineDataBLL geovindu_TimeLineDataBLL = new Geovindu_TimeLineDataBLL();
            /// <summary>
            /// 
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
                    geovindu_TimeLineProjectInfo = geovindu_TimeLineProjectBLL.SelectGeovindu_TimeLineProject(1);
                    geovindu_TimeLineAssetProjectInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetProject(1);
                    selectGeovindu_TimeLineDataProject = geovindu_TimeLineDataBLL.SelectGeovindu_TimeLineDataProject(1);
                    for (int i = 0; i < selectGeovindu_TimeLineDataProject.Count; i++)
                    {
                        selectGeovindu_TimeLineDataProject[i].TimeLineDataAssetInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetData(selectGeovindu_TimeLineDataProject[i].TimeDataID);
                    }
    
                    //context.Response.ContentType = "text/plain";
                    //context.Response.Write("Hello World");
                    geovindu_TimeLineProjectInfo = geovindu_TimeLineProjectBLL.SelectGeovindu_TimeLineProject(1);
                    geovindu_TimeLineAssetProjectInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetProject(1);
                    selectGeovindu_TimeLineDataProject = geovindu_TimeLineDataBLL.SelectGeovindu_TimeLineDataProject(1);
                    for (int i = 0; i < selectGeovindu_TimeLineDataProject.Count; i++)
                    {
                        selectGeovindu_TimeLineDataProject[i].TimeLineDataAssetInfo = geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetData(selectGeovindu_TimeLineDataProject[i].TimeDataID);
                    }
    
                    JObject rss =
                    new JObject(
                        new JProperty("timeline",
                            new JObject(
                                new JProperty("headline", geovindu_TimeLineProjectInfo.TimeHeadline),
                                new JProperty("type", geovindu_TimeLineProjectInfo.TimeType),
                                new JProperty("text", geovindu_TimeLineProjectInfo.TimeText),
                                new JProperty("startDate", geovindu_TimeLineProjectInfo.TimeStartDate.ToString("yyyy,MM,dd")),
                                new JProperty("asset",
                                    new JObject(
                                         new JProperty("media", geovindu_TimeLineAssetProjectInfo.TimeAssetMedia),
                                         new JProperty("credit", geovindu_TimeLineAssetProjectInfo.TimeAssetCredit),
                                         new JProperty("caption", geovindu_TimeLineAssetProjectInfo.TimeAssetCaption))),
                                         new JProperty("date",
                                        from p in selectGeovindu_TimeLineDataProject
                                        orderby p.TimeDataHeadline
                                        select new JObject(
                                            new JProperty("startDate", p.TimeDataStartDate.ToString("yyyy,MM,dd")),
                                            new JProperty("headline", p.TimeDataHeadline),
                                            new JProperty("text", p.TimeDataText),
                                            new JProperty("asset",
                                                new JObject(
                                            //geovindu_TimeLineAssetDataInfo=geovindu_TimeLineAssetBLL.SelectGeovindu_TimeLineAssetData(p.TimeDataID)
                                                     new JProperty("media", p.TimeLineDataAssetInfo.TimeAssetMedia),
                                                     new JProperty("credit", p.TimeLineDataAssetInfo.TimeAssetCredit),
                                                     new JProperty("caption", p.TimeLineDataAssetInfo.TimeAssetCaption)
    
                                                    )))))));
                    Response.Write(rss.ToString());
                    File.WriteAllText(Server.MapPath("geovindu.json"), rss.ToString());
    
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message.ToString());
                }
    
    
    
            }
        }
    }
    
  • 相关阅读:
    07_面向对象(成员变量和局部变量区别、类作为形式参数的问题、匿名对象、封装、private关键字、this关键字、构造方法、成员方法、static关键字、静态变量和成员变量、main方法)_02
    07_面向对象(成员变量和局部变量区别、类作为形式参数的问题、匿名对象、封装、private关键字、this关键字、构造方法、成员方法、static关键字、静态变量和成员变量、main方法)_01
    书单
    06_二维数组【四种格式、打印杨辉三角、Java中参数传递、数据加密案例】、面向对象【对象内存图】
    05_方法(重载)、数组(一维)[数组的初始化、遍历、求最值、逆序、查表]
    04循环结构
    基于视频压缩的实时监控系统
    select 和 epoll 的区别
    CGI 程序编写
    面经获取 20170515
  • 原文地址:https://www.cnblogs.com/geovindu/p/4190345.html
Copyright © 2011-2022 走看看