In general, it is quite easy to remove the Category Navigation WebPart SPSWC:CategoryNavigationWebPart from the SharePoint template. Just open the proper file, locate
<SPSWC:CategoryNavigationWebPart runat=”server” id=”HorizontalNavBar” DisplayStyle=”HorizontalOneLayer” />
and delete it. ( The attributes may differ ).
On certain very stubborn pages, it is just not possible to remove it. For example, take the txtlstvw.aspx page. If you remove the category navigation webpart from this page, you are presented with the following error:
[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.Portal.WebControls.TextListingViewerPage.OnInit(EventArgs ea)
System.Web.UI.Control.InitRecursive(Control namingContainer) +240
System.Web.UI.Page.ProcessRequestMain() +195
I was very curious about it, as most of the pages do not complain so strongly if we remove the webpart from the template. There was no obvious link in the template HTML which proves that some other control uses it, and I removed almost all existing default controls from the page, but the error still persisted. This led me to believe that the error was somewhere in the code-behind for this page.
So I opened Reflector and loaded the Microsoft.SharePoint.Portal.dll and navigated to TextListingViewerPage->OnInit. There I found this piece of code :
this.HorizontalNavBar.CurrentCategoryID = this.BreadCrumbTrail.CurrentID = guid1.ToString();
There was no error checking code before this which tried to check if either HorizontalNavBar or BreadCrumbTrail objects were null. Thus we were stuck here. There is absolutely no way to remove these two webparts from this page without crashing it.
But… There was a sly approach. If I can’t remove them, then I can definitely hide them. My goal was to knock off these and add a custom branding with custom navigation controls. Hence, all I did was surround the Category Navigation Webpart and the Breadcrumb Trail Webpart with
<div style=”display:none;”>…</div>
Do this same trick if you ever have such a problem. I do remember having this problem while branding some other page in SharePoint but cannot remember which one. This is evidently sloppy coding on the part of the coder who wrote that page, and I hope problems like these would be corrected in the future releases.