csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C#.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/// <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());
            }
 
 
 
        }
    }
}

 

posted @   ®Geovin Du Dream Park™  阅读(334)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2012-12-28 Csharp: listview control binding database from datatable
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示