作者:grafopenshaw_460 | 来源:互联网 | 2014-05-27 11:53
前台!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhtmlxmlnshttp://www.w3.org/1999/xhtmlheadtitle无标题页
前台
点击
接收后台数据
hello
后台
protected void Page_Load(object sender, EventArgs e)
{
Hashtable ht = new Hashtable();
string name = Request.Params["name"].ToString();
string birth = Request.Params["birthday"].ToString();
if (!string.IsNullOrEmpty(name) &&
!string.IsNullOrEmpty(birth))
{
//Response.COntentType= "Application/json";
//Response.Write(CreareJson("this is ok!", 1, name, birth));
ht.Add("info", "成功了");
ht.Add("sta", "状态");
ht.Add("name", name);
ht.Add("birth", birth);
Response.Write(CreateJsonParams(ht));
}
Response.End();
}
private string CreateJsonParams(Hashtable items)
{
string returnStr = "";
foreach(DictionaryEntry item in items)
{
returnStr += "\"" + item.Key.ToString() + "\":\"" +
item.Value.ToString() + "\",";
}
return "{" + returnStr.Substring(0,returnStr.Length-1) + "}";
}