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

來源:互聯網
上載者:User

標籤:

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

 

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.