zoukankan      html  css  js  c++  java
  • json转化为对象数组

    1.ascx传值给aspx

    aspx页面

    <%@ Page Title="" Language="C#" MasterPageFile="~/_pub/Master/EasyUIFormPage.master" AutoEventWireup="true" CodeFile="FieldsMatch.aspx.cs" Inherits="XJGL2_FieldsMatch" %>
    <%@ Register TagName="EF" Src="~/_pub/EasyUIUserControl/UC_ExportFields.ascx" TagPrefix="UC" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript">
    function MatchResult()
    {
    var s = "<table width=100% height=100% border=0 cellpadding=0 cellspacing=0 >";
    s += "<tr><td align=center valign=middle >正在导入,请稍后...<br>";
    s += "<marquee id=loadschedule style='border-1px; border-color:SteelBlue;background-color:gainsboro;200;height:12' scrollamount='8' scrolldelay='10' direction='right'>";
    s += "<table width=30 border=0 cellpadding=0 cellspacing=0 height=12>";
    s += "<tr><td style='background-color:DarkBlue; border-style:solid; border-1px; border-color:gainsboro'></td><td style='background-color:DarkBlue; border-style:solid; border-1px; border-color:gainsboro'></td><td style='background-color:DarkBlue; border-style:solid; border-1px; border-color:gainsboro'></td></tr>";
    s += "</table></marquee>";
    s += "</td></tr>";
    s += "</table>";
    main2.msg.innerHTML = s;
    main2.MainRpt.innerHTML = "<asp:Literal ID='Rpt' runat='server'></asp:Literal>";
    form.encoding = "multipart/form-data";
    form.action = "dr_student_rpt.aspx";
    form.target = "main2"
    form.submit();

    }
    </script>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="Content" Runat="Server">
    <table style="100%" border="0" cellspacing="0" cellpadding="0">
    <tr><td style="text-align:center;"><UC:EF ID="FieldsMatch" name="FieldsMatch" runat="server" /></td></tr>
    <tr><td style="text-align:center"><input type="button" id="btnok" value="确定" class="but20" onclick="MatchResult()"></td></tr>
    </table>
    <iframe id="main2" name="main2" src="dr_student_rpt.aspx" width=100% height=96% frameborder=0></iframe>
    </asp:Content>

    提交到dr_student_rpt.asxp后  Request.Form["FieldsMatch"]即可取到ascx控件所传回来的datagrid的json数据

    2.easyui-datagrid json转化为ExportFields对象数组

    public static T FromJson<T>(string jsonText)
    {

    JavaScriptSerializer servializer = new JavaScriptSerializer();
    T result = (T)servializer.Deserialize<T>(jsonText);
    return result;
    }

    public class ExportFields
    {
    public string ExcelColumn { get; set; }
    public string ExportColumn { get; set; }
    public string ExportField { get; set; }
    }

    List<LogicLayer.Util.LogicSuper.ExportFields> stuInfo = FromJson<List<LogicLayer.Util.LogicSuper.ExportFields>>(Request.Form["FieldsMatch"]);

    for (int i = 0; i < stuInfo.Count; i++)
    {
    stu[i] = new LogicLayer.Util.LogicSuper.ExportFields();
    stu[i].ExportColumn = stuInfo[i].ExportColumn;
    stu[i].ExcelColumn = stuInfo[i].ExcelColumn;
    }

    每天进步一点点
  • 相关阅读:
    mac搭建mamp环境
    iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建)
    iOS开发UI篇—UITabBarController简单介绍
    OS开发UI篇—ios应用数据存储方式(归档)
    iOS开发UI篇—ios应用数据存储方式(偏好设置)
    IOS开发UI篇—ios应用数据存储方式(XML属性列表-plist)
    iOS开发UI篇—控制器的View的创建
    iOS开发UI篇—UIWindow简单介绍
    iOS开发UI篇—使用storyboard创建导航控制器以及控制器的生命周期
    IOS开发UI篇—导航控制器属性和基本使用
  • 原文地址:https://www.cnblogs.com/miraclesakura/p/3729155.html
Copyright © 2011-2022 走看看