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 : Sy
 /// <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());
            }



        }
    }
}

目录
相关文章
|
9月前
|
开发框架 JSON JavaScript
ASP.NET Core3.1实战教程---基于Jquery单文件上传
ASP.NET Core3.1实战教程---基于Jquery单文件上传
91 0
|
9月前
|
JSON 前端开发 Java
利用Spring Boot处理JSON数据实战(包括jQuery,html,ajax)附源码 超详细
利用Spring Boot处理JSON数据实战(包括jQuery,html,ajax)附源码 超详细
213 0
|
3月前
|
JSON Java 关系型数据库
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
在Java中,使用mybatis-plus更新实体类对象到mysql,其中一个字段对应数据库中json数据类型,更新时报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
318 4
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
|
6月前
|
存储 JSON 前端开发
jQuery Get 请求参数转换为 JSON
【8月更文挑战第22天】
|
6月前
|
JSON 开发框架 JavaScript
【Azure Developer】使用.Net Core解析JSON的笔记
【Azure Developer】使用.Net Core解析JSON的笔记
|
8月前
|
存储 JSON 前端开发
为什么String跟JSON不是同个东西?
很多人会误解JSON仅仅是序列化后的String,但这样的表述并不完全准确。JSON本质上是以字符串(String)形式表示的数据交换格式,但它不仅仅是一个字符串,而是具有特定语法和结构的字符串。 很经常遇到的一个场景: 后端:我给你返回了一段JSON,你转化下再遍历吧。
|
8月前
|
JSON JavaScript 前端开发
jQuery获取json文件的方法
jQuery获取json文件的方法
73 2
|
8月前
|
JSON 数据格式 微服务
.NET下 支持大小写不敏感的JSON Schema验证方法
有很多应用程序在验证JSON数据的时候用到了JSON Schema。 在微服务架构下,有时候各个微服务由于各种历史原因,它们所生成的数据对JSON Object属性名的大小写规则可能并不统一,它们需要消费的JSON数据的属性名可能需要大小写无关。 遗憾的是,目前的JSON Schema没有这方面的标准,标准中都是大小写敏感的。在类似上述情况下,这给使用JSON Schema进行数据验证造成了困难。
|
9月前
|
JSON 前端开发 JavaScript
jQuery ajax读取本地json文件 三级联动下拉框
jQuery ajax读取本地json文件 三级联动下拉框
|
9月前
|
JSON 数据格式
使用 Gson 将 Map、List等转换为json string
使用 Gson 将 Map、List等转换为json string
236 0

热门文章

最新文章