I'm using Ibuyspy with vb. I tried removing the review this product portion of the code in the html section, but I recieve errors after trying to load the page. Any suggestions?
here's the error: Server Error in '/' Application. -------------------------------------------------------------------------------- Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: An unhandled
exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [NullReferenceException: Object reference not set
to an instance of an object.] IBuySpy.ProductDetailsPage.Page_Load(Object sender, EventArgs e) +371 System.Web.UI.Control.OnLoad(EventArgs e) +55 System.Web.UI.Control.LoadRecursive() +27 System.Web.UI.Page.ProcessRequestMain() +731 --------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
Can you post your page and vb code? I have modified mine so much that it is not even close to the original. You can get that error if you are trying to access a control that doesn't exisit. For example, if your HTML code originally hadwhose value
was modified during the page load: TextBox1.Text = "Hello"and then you remove the HTML that defines the control, your code will crash with the error you mentioned.
here's the VB, thanks for the help, I'm new at this Public Class ProductDetailsPage Inherits System.Web.UI.Page Protected WithEvents ModelName As System.Web.UI.WebControls.Label Protected WithEvents ProductImage As System.Web.UI.WebControls.Image Protected
WithEvents UnitCost As System.Web.UI.WebControls.Label Protected WithEvents ModelNumber As System.Web.UI.WebControls.Label Protected WithEvents addToCart As System.Web.UI.WebControls.HyperLink Protected WithEvents desc As System.Web.UI.WebControls.Label Protected
AlsoBoughtList As C_AlsoBought #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region '******************************************************* ' ' The Page_Load event on this page is
used to obtain ' product information from a database and then update ' UI elements with them. ' ' Note that this page is output cached at 1 minute ' intervals. This eliminates the need to hit the database ' on each request to the page. ' '*******************************************************
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Obtain ProductID from QueryString Dim ProductID As Integer = CInt(Request.Params("ProductID")) ' Obtain Product Details Dim products As IBuySpy.ProductsDB
= New IBuySpy.ProductsDB() Dim myProductDetails As IBuySpy.ProductDetails = products.GetProductDetails(ProductID) ' Update Controls with Product Details desc.Text = myProductDetails.Description UnitCost.Text = String.Format("{0:c}", myProductDetails.UnitCost)
ModelName.Text = myProductDetails.ModelName ModelNumber.Text = myProductDetails.ModelNumber.ToString() ProductImage.ImageUrl = "ProductImages/" & myProductDetails.ProductImage addToCart.NavigateUrl = "AddToCart.aspx?ProductID=" & ProductID AlsoBoughtList.ProductID
= ProductID End Sub End Class
None
0 Points
9 Posts
Removing "review this product"
Dec 12, 2003 08:29 AM|johnnyek|LINK
Member
160 Points
980 Posts
Re: Removing "review this product"
Dec 12, 2003 09:11 AM|wunderkinder|LINK
None
0 Points
9 Posts
Re: Removing "review this product"
Dec 12, 2003 09:35 AM|johnnyek|LINK
None
0 Points
9 Posts
Re: Removing "review this product"
Dec 12, 2003 10:40 AM|johnnyek|LINK
Member
160 Points
980 Posts
Re: Removing "review this product"
Dec 12, 2003 12:37 PM|wunderkinder|LINK
whose value was modified during the page load:
TextBox1.Text = "Hello"
and then you remove the HTML that defines the control, your code will crash with the error you mentioned.None
0 Points
9 Posts
Re: Removing "review this product"
Dec 12, 2003 03:27 PM|johnnyek|LINK
Member
160 Points
980 Posts
Re: Removing "review this product"
Dec 12, 2003 03:42 PM|wunderkinder|LINK
None
0 Points
9 Posts
Re: Removing "review this product"
Dec 12, 2003 04:03 PM|johnnyek|LINK
Product Information:
Model Number:
Price:
>ADD TO CART