当尝试保存订单时,我们首先从会话加载对象。这行得通。然后我们将信息添加到订单中并将其放回会话中。然后我收到对象引用未设置为对象错误的实例。
Private Sub SaveOrder()
'load the order
Order = Session("Order")
'Add order information here
Session("Order") = Order 'The error is occurring here.
End Sub
堆栈跟踪如下:
Error Path: Contact.aspx
Error Detail: Object reference not set to an instance of an object.
Error Source: Void __RenderContent1(System.Web.UI.HtmlTextWriter, System.Web.UI.Control)
Error Stack Trace: at ASP.orderentry_uc3_contact_aspx.__RenderContent1(HtmlTextWriter __w, Control parameterContainer) in C:\Portal Websites\Portals\OrderEntry\UC3\Contact.aspx:line 9
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
对此的任何帮助将不胜感激。
添加了请求的代码:
Imports ComponentArt.Web.UI
Partial Class OrderEntry_UC3_Contact
Inherits Company.Pages.CompanyPage
Public Order As Company.Orders.UC3.Order
Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
If Valid() Then
SaveOrder() 'This is line 9
Response.Redirect("Payment.aspx")
End If
End Sub
我已经添加了 aspx 页面的顶部(整个东西太大了)。
<%@ Page Language="VB" MasterPageFile="~/Portal/PortalNoFooter.master" AutoEventWireup="false"
EnableTheming="true" CodeFile="Contact.aspx.vb" Inherits="OrderEntry_UC3_Contact"
Title="Contact" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
//To large to submit the whole thing
</asp:Content>
enter code here