我在 asp.net 中有一个 web 表单,每次我尝试访问它时,它都会引发以下异常
引发了“System.OutOfMemoryException”类型的异常
它确实进入了页面加载并完成了其中的所有方法,但是一旦应该加载页面,它就会抛出异常。(现在我正在本地主机中尝试)
我不确定问题可能出在哪里。如果您需要示例的一部分,请告诉我。提前致谢
ASP
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="addRefundByStation.aspx.cs" Inherits="Stations_addRefundByStation" %> <%@ Register Assembly="obout_Flyout2_NET" Namespace="OboutInc.Flyout2" TagPrefix="cc1 " %> <%@ 注册 TagPrefix="ew" Namespace="eWorld.UI" Assembly="eWorld.UI, Version=1.9.0.0, Culture=neutral, PublicKeyToken=24d65337282035f2" %>
添加退款
<meta http-equiv="Page-Enter" content="blendTrans(Duration=0.25)" />
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0.25)" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<link href="../styles.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
function cambiar()
{
__doPostBack('btnChange','');
}
function loadPage(url)
{
var id = window.showModalDialog(url,'','dialogWidth:540px; dialogHeight:450px; toolbar:no; resizable:no; help:no; scroll:no; status:no;');
}
function viewCalendars()
{
if (screen.width <= 1024)
{
if (document.getElementById('ddlDates').value == '3')
{
document.getElementById('divSpecificDates').style.display='inline';
document.getElementById('divRowBlank').style.display='inline';
document.getElementById('divSpace1024').style.display='inline';
document.getElementById('divResolution').style.display='inline';
document.getElementById('divSpace1024Dates').style.display='none';
document.getElementById('divResolutionWithoutFilter').style.display='none';
}
else
{
document.getElementById('divSpecificDates').style.display='none';
document.getElementById('divRowBlank').style.display='none';
document.getElementById('divSpace1024').style.display='inline';
document.getElementById('divSpace1024Dates').style.display='inline';
document.getElementById('divResolutionWithoutFilter').style.display='inline';
}
document.getElementById('divRowBlank').style.display='none';
}
else
{
document.getElementById('divResolution').style.display = 'none';
if(document.getElementById('ddlDates').value == '3')
{
document.getElementById('divSpecificDates').style.display='inline';
document.getElementById('divRowBlank').style.display='inline';
document.getElementById('divSpace').style.display='none';
document.getElementById('divSpace1024').style.display='inline';
}
else
{
document.getElementById('divSpecificDates').style.display='none';
document.getElementById('divRowBlank').style.display='none';
document.getElementById('divSpace').style.display='inline';
document.getElementById('divSpace1024').style.display='inline';
}
}
return;
}
function GoBack()
{
document.location.href = '../Stations/listRefunds.aspx?idStation=<% = Request["idStation"] %>';
}
</script>
</head>
<body style="padding: 0px 0px 0px 0px;" onload="viewCalendars();">
<form id="form1" runat="server">
<input type="hidden" runat="server" id="hdnIdStation" value="-1" />
<asp:ScriptManager ID="smInvoice" runat="server">
</asp:ScriptManager>
<table style="width:100%;position: absolute; top: 13px; left: 10px;"
cellpadding="0" cellspacing="0" border="0">
<tr>
<td visible="false" style="width:75%;" valign="top" runat="server" id="tdConsumption">
<table style="width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="leftSub" style="width:10px; height: 30px;" />
<td class="subTitle" style="width: 55%; height: 30px;">
Consumos -
<asp:Label ID="lblStation" runat="server">
</asp:Label>
</td>
<td style="text-align: right; height: 39px;" class="subTitle">
<a href="javascript:GoBack();" style="color:White; font-size:12px; font-weight:bold; text-decoration:none;">
<img alt="Regresar" src="../images/icons/arrow-Back.gif" />
Regresar
</a>
<asp:ImageButton ID="imgBtnAdd" runat="server" ImageUrl="../images/icons/plus.png" OnClick="imgBtnAdd_Click" />
<asp:Label ID="lblAdd" runat="server" Text="Agregar Consumo" Font-Size="12px" Font-Bold="True" ForeColor="white" OnClick="imgBtnAdd_Click">
</asp:Label>
</td>
<td class="rightSub" style="width:10px; height: 30px;" />
</tr>
<tr>
<td class="leftTop" style="width:10px;" />
<td class="top" colspan="2" />
<td class="rightTop" style="width:10px;" />
</tr>
<tr>
<td class="left" style="width:10px;" />
<td class="generic" colspan="2">
Fecha del Estado de Cuenta:
<ew:CalendarPopup ID="cldDate" runat="server" JavascriptOnChangeFunction="javascript:cambiar();" >
</ew:CalendarPopup>
<br />
Buscar:
<asp:TextBox runat="server" onkeydown="javascript:ValidarEnter()" CssClass="tbox" Width="100px" ID="tbxSearch">
</asp:TextBox>
<asp:RequiredFieldValidator ID="rfvBeginDate" runat="server" ControlToValidate="tbxBeginDate">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="rfvEndDate" runat="server" ControlToValidate="tbxEndDate">
</asp:RequiredFieldValidator>
Fechas:
<asp:DropDownList ID="ddlDates" CssClass="tbox" runat="server">
</asp:DropDownList>
<div style="display: inline;" id="divSpace">
</div>
<div runat="server" id="divSpecificDates" style="display: none; width: 98%;">
<div style="width: 80%; display: inline;">
</div>
Desde:
<ew:CalendarPopup ID="tbxBeginDate" runat="server">
</ew:CalendarPopup>
<div style="display: none" id="divResolution">
<table cellpadding="0" cellspacing="0">
<tr>
<td height="4px" />
</tr>
</table>
</div>
<div style="display: inline;" id="divSpace1024Dates">
</div>
Hasta:
<ew:CalendarPopup ID="tbxEndDate" runat="server" >
</ew:CalendarPopup>
</div>
<div style="display: none" id="divRowBlank">
<table cellpadding="0" cellspacing="0">
<tr>
<td height="4px" />
</tr>
</table>
</div>
<asp:Button Text="Filtrar" CssClass="btn" runat="server" ID="btnFilter" OnClick="btnFilter_Click" />
<br />
<asp:UpdatePanel ID="upd" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="Large" Text="Consumos Pendientes: ">
</asp:Label>
<asp:Label ID="lblTotalAmount" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="Large" ForeColor="Red">
</asp:Label>
<div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
<td class="right" style="width:10px;" />
</tr>
<tr>
<td class="left" style="width:10px;" />
<td colspan="2" valign="top">
<asp:GridView ID="grvConsumption" runat="server" DataKeyNames="idConsumption"
AllowPaging="true" AutoGenerateColumns="false" PageSize="50" Width="98%"
CssClass="borders" HeaderStyle-CssClass="subT" AllowSorting="true"
AlternatingRowStyle-CssClass="txtB" RowStyle-CssClass="txtA"
OnPageIndexChanging="grvConsumption_PageIndexChanging"
OnSorting="grvConsumption_Sorting" OnRowDataBound="grvConsumption_RowDataBound">
<PagerStyle HorizontalAlign="Right" CssClass="texto" />
<EmptyDataTemplate>
<asp:Literal ID="ltNoInformationFound" runat="server">
No se encontraron Consumos
</asp:Literal>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="" Visible="false">
<ItemTemplate>
<asp:Label ID="lblConsumption" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.idConsumption") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="" Visible="false">
<ItemTemplate>
<asp:Label ID="lblTypeDesc" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.TypeDesc") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderText="ID" DataField="idConsumption" SortExpression="idConsumption" HtmlEncode="False" />
<asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderText="Tarjeta" DataField="cardCode" SortExpression="cardCode" HtmlEncode="False" />
<asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderText="Fecha" SortExpression="dateCreated">
<ItemTemplate>
<%# string.Format("{0:dd/MM/yyyy}",((DateTime)(DataBinder.Eval(Container.DataItem, "dateCreated"))))%>
<br>
<%# ((DateTime)(DataBinder.Eval(Container.DataItem, "dateCreated"))).ToString("hh:mm tt") %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderText="Cantidad" DataField="quantity" SortExpression="quantity" DataFormatString="{0:##,##0.000}" HtmlEncode="False" />
<asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderText="Descripción" DataField="description" SortExpression="description" />
<asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderText="P. Unitario" DataField="price" SortExpression="price" DataFormatString="{0:#,$##0.00}" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" />
<asp:BoundField HeaderStyle-HorizontalAlign="Left" HeaderText="Total" DataField="total" SortExpression="total" DataFormatString="{0:C}" HtmlEncode="False" ItemStyle-HorizontalAlign="Right" />
<asp:TemplateField itemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Left" HeaderText="Iva" SortExpression="tax">
<ItemTemplate >
<%# DataBinder.Eval(Container.DataItem, "tax").ToString() + " %" %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="center">
<HeaderStyle Font-Bold="false" />
<ItemTemplate>
<asp:CheckBox runat="server" ID="ckbChange" />
</ItemTemplate>
<HeaderTemplate>
Sel. todos
<asp:CheckBox ID="cbxSelectAll" runat="server" AutoPostBack="true" OnCheckedChanged="cbxSelectAll_OnCheckedChanged" />
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="imgCoupon" runat="server" ImageUrl="~/images/icons/coupon.gif" Visible='<%# Eval("couponConsumption") %>' />
<cc1:Flyout ID="Flyout1" runat="server" Position="MIDDLE_LEFT" AttachTo="imgCoupon" Visible='<%# Eval("couponConsumption") %>'>
<table cellspacing="0" cellpadding="0" border="0" id="tblEdit" runat="server" style="width: 100px">
<tr>
<td class="leftSub" />
<td class="subTitle">
<asp:Label ID="Label3" runat="server" ForeColor="white" Font-Bold="True" Font-Size="12px" Text="Vales">
</asp:Label>
</td>
<td class="subTitle" align="left" />
<td class="rightSub" />
</tr>
<tr>
<td class="leftTop" />
<td class="top" colspan="2" />
<td class="rightTop" />
</tr>
<tr>
<td class="left" />
<td valign="middle" align="center" colspan="2" style="background-color:White;">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("couponConsumtion") %>'>
</asp:Label>
</td>
<td class="right" />
</tr>
<tr>
<td class="leftBtm" style="height: 22px" />
<td class="btm" colspan="2" style="height: 22px" />
<td class="rightBtm" style="height: 22px" />
</tr>
</table>
</cc1:Flyout>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle CssClass="txtB" />
<EmptyDataRowStyle HorizontalAlign="Center" CssClass="tboxCombo" ForeColor="DarkGoldenrod" BorderWidth="0" />
</asp:GridView>
</td>
<td class="right" style="width:10px;" />
</tr>
<tr>
<td class="leftBtm" style="width:10px;" />
<td class="btm" colspan="2" />
<td class="rightBtm" style="width:10px;" />
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" runat="server" id="hdnConsumption" value="-1" />
<input type="hidden" runat="server" id="hdnSort" />
<input type="hidden" runat="server" id="hdnTotal" value="-1" />
<input type="hidden" runat="server" id="hdnTax" value="-1" />
</form>
</body>
CS
//各种用法
public partial class Stations_addRefundByStation : BasePage { protected void Page_Load(object sender, EventArgs e) { //imgBtnSaveRefund.Attributes.Add("onclick", base.DisableButton(imgBtnSaveRefund, true, true).ToString());
if (!IsPostBack)
{
dblSubtotal = 0;
if (Request["idStation"] != null)
{
int intIdStation = int.Parse(Request["idStation"]);
hdnIdStation.Value = intIdStation.ToString();
Station objStation = new Station(intIdStation);
aCancel.HRef = "../Stations/listRefunds.aspx?idStation=" + intIdStation;
Dates();
lblStation.Text = objStation.shortname;
tbxPayMethod.Text = objStation.payMethod;
tbx4Digits.Text = objStation.fourDigitAccount;
tbxBeginDate.SelectedDate = tbxEndDate.SelectedDate = DateTime.Now;
this.EnableViewState = true;
loadData();
loadDdlDates();
rememberOldFiltersValues();
}
else
{
Response.Redirect("~/Administration/detailStation.aspx");
}
}
}
private void loadData()
{
//dtConsumption = Consumption.listTableByClient(client.id);
dtConsumption = Consumption.GetConsumptionTable(DateTime.Now.AddYears(-100), DateTime.Now.AddYears(100), -1, int.Parse(hdnIdStation.Value), false);
ViewState.Add(VSN.dtListConsumptions, dtConsumption);
DataColumn[] keys = new DataColumn[1];
keys[0] = (DataColumn)dtConsumption.Columns[0];
dtConsumption.PrimaryKey = keys;
loadGridView();
dtSource = dtConsumption.Clone();
ViewState.Add(VSN.dtSource, dtSource);
lblQuantity.Text = dtSource.Rows.Count.ToString();
lblSubTotal.Text = dblSubtotal.ToString("C");
lblTax.Text = dblTax.ToString("C");
lblTotal.Text = dblTotal.ToString("C");
lblCommissionAmount.Text = dblCommissionAmount.ToString("C");
lblCommissionTaxAmount.Text = dblCommissionTaxAmount.ToString("C");
lblPendingAmount.Text = dblPendingAmount.ToString("C");
if (dtConsumption.Rows.Count != 0)
{
lblTotalAmount.Text = double.Parse(dtConsumption.Compute("sum(total)", string.Empty).ToString()).ToString("C");
}
else
{
lblTotalAmount.Text = "$0.00";
}
}
private void loadDdlDates()
{
ddlDates.Items.Insert(0, new ListItem("Seleccionar...", "-1"));
ddlDates.Items.Insert(1, new ListItem("Este mes", "1"));
ddlDates.Items.Insert(2, new ListItem("Este año a la Fecha", "2"));
ddlDates.Items.Insert(3, new ListItem("Fechas Específicas", "3"));
ddlDates.Attributes.Add("onChange", "javascript:viewCalendars();");
}
private void loadGridView()
{
grvConsumption.DataSource = dtConsumption;
grvConsumption.DataBind();
}
private void Dates()
{
DateTime dates = cldDate.SelectedDate;
if (dates.DayOfWeek == DayOfWeek.Saturday)
{
tbxDueDate.SelectedDate = dates.AddDays(2);
}
else if (dates.DayOfWeek == DayOfWeek.Sunday)
{
tbxDueDate.SelectedDate = dates.AddDays(1);
}
else
{
tbxDueDate.SelectedDate = dates;
}
}
protected DatesParams GetDates()
{
return new DatesParams().GetDatesParams(tbxBeginDate.SelectedDate, tbxEndDate.SelectedDate, ddlDates.SelectedValue);
}
private void rememberOldFiltersValues()
{
if (Session[SN.filtersRefundByStation] != null)
{
filterUtility filters = (filterUtility)Session[SN.filtersRefundByStation];
ddlDates.SelectedValue = filters.idDatesFilter.ToString();
tbxSearch.Text = filters.searchCriteria;
if (filters.idDatesFilter != -1)
{
tbxBeginDate.SelectedDate = filters.startDate;
tbxEndDate.SelectedDate = filters.endDate;
}
}
}
public static DataTable dataViewAsDataTable(DataView dv)
{
DataTable dt = dv.Table.Clone();
foreach (DataRowView drv in dv)
{
dt.ImportRow(drv.Row);
}
return dt;
}
protected DatesCriteria getCriteria()
{
return (new DatesCriteria()).getDatesCriteria(tbxBeginDate.SelectedDate, tbxEndDate.SelectedDate, ddlDates.SelectedValue);
}
protected void imgBtnAdd_Click(object sender, ImageClickEventArgs e)
{
//Not used for now
}
protected void grvConsumption_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView gridView = (GridView)sender;
if (e.Row.RowType == DataControlRowType.Header)
{
int cellIndex = -1;
foreach (DataControlField field in gridView.Columns)
{
if (field.SortExpression == "quantity" || field.SortExpression == "description" || field.SortExpression == "price" || field.SortExpression == "total" || field.SortExpression == "dateCreated" || field.SortExpression == "tax" || field.SortExpression == "idConsumption" || field.SortExpression == "name" || field.SortExpression == "cardCode")
{
cellIndex = gridView.Columns.IndexOf(field);
e.Row.Cells[cellIndex].CssClass = "headerstyle";
if (hdnSort.Value.StartsWith(field.SortExpression))
{
if (hdnSort.Value.EndsWith("asc"))
{
e.Row.Cells[cellIndex].CssClass = "sortascheaderstyle";
}
else if (hdnSort.Value.EndsWith("desc"))
{
e.Row.Cells[cellIndex].CssClass = "sortdescheaderstyle";
}
}
}
if (field.SortExpression == "")
{
e.Row.Cells[gridView.Columns.IndexOf(field)].CssClass = "subT";
}
}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblConsumption = (Label)e.Row.Cells[0].FindControl("lblConsumption");
e.Row.Attributes.Add("onmouseover", "this.className='mouseOverWithOutHand'");
if (e.Row.RowIndex % 2 == 0 && lblConsumption.Text != hdnConsumption.Value)
{
e.Row.Attributes.Add("onmouseout", "this.className='txtA'");
}
else if (lblConsumption.Text != hdnConsumption.Value)
{
e.Row.Attributes.Add("onmouseout", "this.className='txtB'");
}
if (lblConsumption.Text == hdnConsumption.Value)
{
e.Row.Attributes.Add("onmouseout", "this.className='subT2'");
e.Row.CssClass = "subT2";
}
}
}
}