标签:des c style class blog code
后台:
public static string TrendChart() { HttpContext context = HttpContext.Current; ReturnStr strReturn = new ReturnStr(); JavaScriptSerializer serializer = new JavaScriptSerializer(); strReturn.msg = serializer.Serialize(list); strReturn.other = ExcelName; strReturn.oldname = priceType; strReturn.count = ProductID.Count; strReturn.success = true; if (context.Session["Object"] != null) { context.Session.Remove("Object"); } context.Session["Object"] = strReturn; return serializer.Serialize(strReturn); }
前台:
$("#btnTrendChart").bind("click", function () { var jsonData = { path: "/CollectAnalysis/LivelihoodAnalysis/ViewProductDetails.aspx/TrendChart", param: {} } var resultData = _Fun.jQueryAjax(jsonData); if (resultData.info) { WindowsOutOpen("ProductTrendChart.aspx"); } });
还可以
$("#btnTrendChart").bind("click", function () { var jsonData = { path: "/CollectAnalysis/LivelihoodAnalysis/ViewProductDetails.aspx/TrendChart", param: {} } var _myJson = { info: true }; showProgress(0, "正在整理数据中,请稍候..."); $.ajax({ type: "POST", async: true, url: jsonData.path, data: JSON.stringify(jsonData.param), dataType: "json", contentType: "application/json;charset=utf-8", success: function (data) { _myJson.info = JSON.parse(data.d); if (_myJson.info.success) { WindowsOutOpen("ProductTrendChart.aspx"); } hideProgress(); }, error: function () { hideProgress(); error(‘服务器未响应,请联系管理员!‘); } }); });
这种可以添加进度条:showProgress(0, "正在整理数据中,请稍候...");
ProductTrendChart.aspx后台代码:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { if (Session["Object"] == null) { //如果没有要导出的Session对象 return; } jsonObject = Session["Object"] as ReturnStr; string jsonlist = jsonObject.msg; JavaScriptSerializer Serializer = new JavaScriptSerializer(); list = Serializer.Deserialize<List<Models.livelihooddatachecked>>(jsonlist); } catch { } } }
ajax利用session传值到前台(案例),布布扣,bubuko.com
标签:des c style class blog code
原文地址:http://www.cnblogs.com/gbnw/p/3776097.html