Page 1 of 1
Object reference not set to an instance of an object error.
Posted: Tue Nov 03, 2009 12:51 pm
by DBounlom
Hi,
I am getting this error.
Exception of type 'System.Web.HttpUnhandledException' was thrown.; Object reference not set to an instance of an object.
When I look in the app.log I see this,
ERROR 2009-11-03 14:46:34,776 55718812ms Object a - An error has occured at
http://www.x.com/CategoryGrid4.aspx?CategoryId=108
System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at ASP.CategoryListEx.ExpandSelectedPath()
at ASP.CategoryListEx.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.categorygrid4_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Does anyone know what this means or how I can fix it? If someone needs more information, then please direct me on what I should do. Sorry, I'm a newbie.

Thanks a million for any help.
Re: Object reference not set to an instance of an object error.
Posted: Tue Nov 03, 2009 4:03 pm
by jmestep
Did you customize the page?
Did you try it with a different category display page?
Do you have an active category with an id of 108?
Re: Object reference not set to an instance of an object error.
Posted: Tue Nov 03, 2009 4:37 pm
by DBounlom
Dear Judy,
Thanks for replying.
Did you customize the page?
I changed the categorygrid4.aspx a little bit. I wanted the initial sorting of a category to be how it is like in admin mode, so I followed the OP from here.
viewtopic.php?f=42&t=6661&p=50795&hilit ... der#p50795
Did you try it with a different category display page?
Yes, you are right. The category page loads fine with a different display page. For instance, it will load with categorygrid2.aspx, but it errors out when I switch it back to categorygrid4.aspx. One difference between the two displays, is that for categorygrid4 I am using standard sidebar 1 and shopping bar 1 for my left sidebar and right sidebar, respectively. Out of those two sidebars, the only thing I changed was in the standard sidebar 1 scriptlet I have this
[[conlib:SimpleCategoryList CategoryId="0"]]
instead of the default
[[conlib:SimpleCategoryList]]
However, all of my other category pages load fine, so I doubt it is related to my standard sidebar 1 change. It has to be my categorygrid4.aspx file right? Here is the file.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CategoryGridPage4.ascx.cs" Inherits="ConLib_CategoryGridPage4" %>
<%--
<conlib>
<summary>A category page that displays all contents in a grid format. This page displays products, webpages, and links.</summary>
<param name="DefaultCaption" default="Catalog">Caption text that will be shown as caption when root category will be browsed.</param>
<param name="DisplayBreadCrumbs" default="true">Indicates wheather the breadcrumbs should be displayed or not, default value is true.</param>
<param name="PagingLinksLocation" default="BOTTOM">Indicates where the paging links will be displayd, possible values are "TOP", "BOTTOM" and "TOPANDBOTTOM".</param>
<param name="MaximumSummaryLength" default="250">Maximum characters to display for summary.</param>
</conlib>
--%>
<%@ Register Src="~/ConLib/CategoryBreadCrumbs.ascx" TagName="CategoryBreadCrumbs" TagPrefix="uc" %>
<%@ Register Src="~/ConLib/CategorySearchSidebar.ascx" TagName="CategorySearchSidebar" TagPrefix="uc" %>
<%@ Register Src="~/ConLib/Utility/ProductPrice.ascx" TagName="ProductPrice" TagPrefix="uc" %>
<%@ Register Src="~/ConLib/AddToCartLink.ascx" TagName="AddToCartLink" TagPrefix="uc" %>
<ajax:UpdatePanel ID="SearchResultsAjaxPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="CategoryHeaderPanel" runat="server" EnableViewState="false">
<uc:CategoryBreadCrumbs id="CategoryBreadCrumbs1" runat="server" HideLastNode="True" />
<div class="pageHeader">
<h1><asp:Literal ID="Caption" runat="server" EnableViewState="False"></asp:Literal></h1>
</div>
</asp:PlaceHolder>
<asp:PlaceHolder ID="CategoryDescriptionPanel" runat="server" EnableViewState="false">
<asp:Literal ID="CategoryDescription" runat="server" Text="" EnableViewState="false" />
<br /><br />
</asp:PlaceHolder>
<asp:PlaceHolder ID="phCategoryContents" runat="server">
<div class="searchSortHeader">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr>
<td align="left">
<asp:Localize ID="ResultIndexMessage" runat="server" Text="Displaying items {0} - {1} of {2}" EnableViewState="false"></asp:Localize>
</td>
<td align="right">
<asp:Label ID="SortResultsLabel" runat="server" Text="Sort:" SkinID="FieldHeader" EnableViewState="false" AssociatedControlID="SortResults"></asp:Label>
<asp:DropDownList ID="SortResults" runat="server" AutoPostBack="true" CssClass="sorting" EnableViewState="false">
<asp:ListItem Text="Sort" Value="" Selected="True"></asp:ListItem>
<asp:ListItem Text="By Name (A -> Z)" Value="Name ASC"></asp:ListItem>
<asp:ListItem Text="By Name (Z -> A)" Value="Name DESC"></asp:ListItem>
<asp:ListItem Text="Featured" Value="IsFeatured DESC, Name ASC"></asp:ListItem>
<asp:ListItem Text="By Price (Low to High)" Value="Price ASC"></asp:ListItem>
<asp:ListItem Text="By Price (High to Low)" Value="Price DESC"></asp:ListItem>
<asp:ListItem Text="By Manufacturer (A -> Z)" Value="Manufacturer ASC"></asp:ListItem>
<asp:ListItem Text="By Manufacturer (Z -> A)" Value="Manufacturer DESC"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</div>
<!-- Top Bar -->
<div class="catalogWrapper">
<asp:PlaceHolder ID="PagerPanelTop" runat="server">
<div class="paging">
<asp:Repeater ID="PagerControlsTop" runat="server" OnItemCommand="PagerControls_ItemCommand" EnableViewState="true">
<ItemTemplate>
<a class='<%#Eval("TagClass")%>' href='<%#Eval("NavigateUrl")%>'><%#Eval("Text")%></a>
</ItemTemplate>
</asp:Repeater>
</div>
</asp:PlaceHolder>
<asp:DataList ID="CatalogNodeList" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" Width="100%"
OnItemDataBound="CatalogNodeList_ItemDataBound" DataKeyField="CatalogNodeId" CssClass="catalog" EnableViewState="false" HorizontalAlign="Left">
<ItemStyle HorizontalAlign="center" VerticalAlign="top" Width="33%" CssClass="tableNode" />
<ItemTemplate>
<asp:PlaceHolder ID="phItemTemplate1" runat="server"></asp:PlaceHolder>
<uc:ProductPrice ID="Price" runat="server" Product='<%#Container.DataItem%>' ShowRetailPrice="True" />
<asp:PlaceHolder ID="phItemTemplate2" runat="server"></asp:PlaceHolder>
<div style="margin-top:10px;margin-bottom:20px" id="Add2CartLinkDiv" runat="server" visible='<%#((CatalogNodeType)Eval("CatalogNodeType")) == CatalogNodeType.Product %>'><uc:AddToCartLink ID="Add2Cart" runat="server" ProductId='<%#Eval("CatalogNodeId")%>' visible='<%#((CatalogNodeType)Eval("CatalogNodeType")) == CatalogNodeType.Product %>' /></div>
</ItemTemplate>
<SeparatorTemplate> </SeparatorTemplate>
<SeparatorStyle CssClass="separator" Width="1" />
</asp:DataList><br clear="all" />
<asp:PlaceHolder ID="PagerPanel" runat="server">
<div class="paging">
<asp:Repeater ID="PagerControls" runat="server" OnItemCommand="PagerControls_ItemCommand" EnableViewState="true">
<ItemTemplate>
<a class='<%#Eval("TagClass")%>' href='<%#Eval("NavigateUrl")%>'><%#Eval("Text")%></a>
</ItemTemplate>
</asp:Repeater>
</div>
</asp:PlaceHolder>
</div>
<asp:HiddenField ID="HiddenPageIndex" runat="server" Value="0" />
</asp:PlaceHolder>
<asp:PlaceHolder ID="phEmptyCategory" runat="server" Visible="false" EnableViewState="false">
<div align="center">
<asp:Localize ID="EmptyCategoryMessage" runat="server" Text="The category is empty." EnableViewState="false"></asp:Localize>
</div>
</asp:PlaceHolder>
</ContentTemplate>
</ajax:UpdatePanel>
Again, I think in that file, everything is default except for this line I added.
<asp:ListItem Text="Sort" Value="" Selected="True"></asp:ListItem>
I appreciate any insight on this. Thank you.
Re: Object reference not set to an instance of an object error.
Posted: Tue Nov 03, 2009 4:46 pm
by DBounlom
As another side note, I take out that line of code I put in for the sorting,
<asp:ListItem Text="Sort" Value="" Selected="True"></asp:ListItem>
and it still errors on me. =(
Re: Object reference not set to an instance of an object error.
Posted: Wed Nov 04, 2009 6:26 am
by jmestep
You should compare your CategoryGrid4 against the default one to see what is missing. You can use a program like BeyondCompare from ScooterSoftware- I think they have a free trial version.
Re: Object reference not set to an instance of an object error.
Posted: Wed Nov 04, 2009 3:38 pm
by DBounlom
I know I should've made a backup before I started tinkering w/ the default categorygrid4, but I'm an idiot. =( Is there a way to get the default categorygrid4.aspx somewhere? Thanks.
Re: Object reference not set to an instance of an object error.
Posted: Wed Nov 04, 2009 3:41 pm
by jmestep
It should be in your original install package. If you don't have that, pm me with your email address and tell me what build and I will send you one.
Re: Object reference not set to an instance of an object error.
Posted: Thu Nov 05, 2009 1:36 pm
by DBounlom
Thanks for the e-mail of the default categorygridpage4.ascx. The file you sent me and the file that I had was exactly the same. I even simply replaced the file on the server with yours, and I still get that stupid error. Other category pages on the site work fine. Should I just delete this category page and remake it? I know of at least two category pages that do this on our site, so far. I am really confused. Any other suggestions? Thanks.
Re: Object reference not set to an instance of an object error.
Posted: Thu Nov 05, 2009 2:42 pm
by DBounlom
I noticed the product page within that category page loads up as an error as well. Is there a way to debug this error in more detail? Thanks.
Re: Object reference not set to an instance of an object error.
Posted: Thu Nov 05, 2009 3:48 pm
by jmestep
It could possibly be a menu or something else on the page that is the problem. Did you change the code for any of that?
Re: Object reference not set to an instance of an object error.
Posted: Fri Nov 06, 2009 1:48 pm
by DBounlom
No, I am using defaults. How do I compile this error in debug mode? I really want to get to the bottom of this problem.

Thanks.
Re: Object reference not set to an instance of an object error.
Posted: Mon Nov 09, 2009 12:51 pm
by DBounlom
Nevermind. I figured it out. One of the employees put some crazy code in standard sidebar 1. I restored it to default, and everything works fine. Thanks for the help Judy.
Re: Object reference not set to an instance of an object error.
Posted: Fri Jan 08, 2010 6:50 am
by jmestep
Ironically, we just had trouble with the same menu- CategoryListEx posted earlier on the forum. It wasn't checking for null on the treeNode in the ExpandSelectedPath()
if (treeNode != null)
{
treeNode.Selected = true;
treeNode.Expand();
}
}