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

时间:2022-09-01 16:10:49
 /// <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#.的更多相关文章

  1. Array&lpar;数组&rpar;与Json String &lpar;Json字符串&rpar; 的相互转换

    1.Array转换成Json String             function jsonToString(arr) {             var s = "";     ...

  2. json string 与object 之间的转化

    1.将json string转化成object 1: public static T GetObjectFromJson<T>(string jsonString) 2: { 3: Dat ...

  3. perl malformed JSON string&comma; neither tag&comma; array&comma; object&comma; number&comma; string or atom&comma; at character offset

    [root@wx03 ~]# cat a17.pl use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' = ...

  4. Jackson将json string转为Object,org&period;json读取json数组

    从json文件读取json string或者自定义json string,将其转为object.下面采用的object为map,根据map读取json的某个数据,可以读取第一级的数据name,后来发现 ...

  5. Convert List&lt&semi;Entity&gt&semi; to Json String&period;

    public static string ToJson(this object obj, string datetimeformats) {     var timeConverter = new I ...

  6. 解决 Jackson反序列化 Unexpected token &period;&period;&period; &comma; expected VALUE&lowbar;STRING&colon; need JSON String that contains type id &lpar;for subtype of &period;&period;&period;&rpar;

    首先检查是否是 objectMapper.enableDefaultTyping(); 的受害者.优先考虑删除该配置. 使用Jackson把数组的json字符串反序列化为List时候报了个JsonMa ...

  7. You&&num;39&semi;re trying to decode an invalid JSON String JSON返回有解析问题

    SpringMVC架构的web程序,通常用map返回消息在浏览器中显示,但是实际中报下列错误“”You're trying to decode an invalid JSON String“返回的字符 ...

  8. How to remove null value in json string

    Hi I'm using the below class Public List<string> name; Public List<string> midname; Once ...

  9. FastJSON 简介及其Map&sol;JSON&sol;String 互转

    在日志解析,前后端数据传输交互中,经常会遇到 String 与 map.json.xml 等格式相互转换与解析的场景,其中 json 基本成为了跨语言.跨前后端的事实上的标准数据交互格式.应该来说各个 ...

随机推荐

  1. Android 自定义回调

    刚开始接触的时候,觉得 回调 是一个很难理解的概念,之后就不停的上网查找回调的定义:(当你想要把具体的操作,让具体的人来完成,自己定义一个接口就好.使用的时候用接口,具体的人来实现你的接口,也就是实现 ...

  2. 2018上C语言程序设计(高级)作业- 第3次作业成绩

    作业地址 https://edu.cnblogs.com/campus/hljkj/CS2017-01/homework/1779 评分准则 第一次作业各项成绩包括三项: 完成PTA所有题目:13分 ...

  3. Idea环境下git 图形化操作

    大家好,之前我们介绍了<IDEA环境下GIT操作浅析之一Idea下仓库初始化与文件提交涉及到的基本命令>和<IDEA环境下GIT操作浅析之二-idea下分支操作相关命令>,本文 ...

  4. 转载:分布式文件系统 - FastDFS 在 CentOS 下配置安装部署(1)

    原文:http://blog.mayongfa.cn/192.html 一.安装 libfastcommon 和 FastDFS 1.下载安装 libfastcommon ,这里是通过wget下载(我 ...

  5. Summary&colon; gcd最大公约数、lcm最小公倍数算法

    欧几里德算法 欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数.其计算原理依赖于下面的定理: 定理:gcd(a,b) = gcd(b,a mod b) 证明:a可以表示成a = kb + ...

  6. 复制控件出错--提示XX控件不存在

    有时候比较喜欢复制粘贴,但是结果就是,经常出现XX控件找不到,或者不存在之类的话~~ 错误如下: 在相当郁闷的时候,尝试了一种很土土的方法,就是直接新建一个同名新页面,把前台和后台的代码复制进去~~ ...

  7. eclipse&sol;myeclipse清除workspace

    打开Eclipse后,选择功能菜单里的 Windows -> Preferences->, 弹出对话框后,选择 General -> Startup and Shutdownwor ...

  8. 如何在centos下配置redis开机自启动

    2014/11/10补充:其实在redis的下载包中就包含了官方自带的启动脚本,路径在/redis-stable/utils/redis_init_script.在utils目录下也有安装redis- ...

  9. 20155301 滕树晨linux基础——linux进程间通信(IPC)机制总结

    20155301 滕树晨linux基础--linux进程间通信(IPC)机制总结 共享内存 共享内存是在多个进程之间共享内存区域的一种进程间的通信方式,由IPC为进程创建的一个特殊地址范围,它将出现在 ...

  10. sql中合并列方法

    方法一:创建合并列函数 -------创建一个方法---------- CREATE FUNCTION dbo.Role_Name(@AdminID int) ) AS BEGIN ) SET @r ...