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;
}