Pages

Monday, May 23, 2011

Showing Headings in Top Navigation Fly-out Menus

I have been fighting with the bad magic that is SharePoint recently, and one of the (many) problems I was having is that the design called for Headings to show up in the drop down menus, but we just could not get them to show up. It was very difficult to find information on this, mainly because there are so many options and configuration choices for a SharePoint site that few solutions are ever straightforward or even applicable to how you have the site set up. I never found a direct explanation of how to get Headers in the drop down (flyout) menus, but luckily I found the solution by chance on a page explaining something else.
The first step is to make sure your site is set up correctly to use drop down menus. This article provides a good explanation. If you are just using WSS 3.0 instead of MOSS 2007, you will likely have to look somewhere else, as I’m pretty sure this will only work with the full product.
Once your site is set up, it’s easy to build out nice looking menus using the Navigation page in the Site Settings, but the headings won’t show up on the drop downs, at least with a Team Site Collection, it may be different with some of the other site types.
These changes need to be made to the master page you are using for the site, and to the administration master page if you want it to show up the same on those pages.
Add the following to the top of the page, under the other control declarations:

<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

Add this right under the first SharePoint:ASPMenu‘s closing tag:

<publishingnavigation:PortalSiteMapDataSource ID="siteMapDataSource1" Runat="server" SiteMapProvider="CombinedNavSiteMapProvider" EnableViewState="true" StartFromCurrentNode="true" StartingNodeOffset="0" ShowStartingNode="true" TreatStartingNodeAsCurrent="true" />


Change the DataSourceID in the SharePoint:AspMenu control to siteMapDataSource1.
That’s it. Your Headings should now show up in the top navigation drop down menus.

Thursday, May 5, 2011

Using Image as Embedded Resource for ASP.NET CustomControl

I started writing an ASP.NET Custom Server Control, where I wanted an Image to be Embedded Resource of the Assembly itself,
so that, I do not need to ship the images separately, but surprisingly it did not work straightway for me.
Solution:
After investigating a bit,
1. The resource URL in my code, (but still it did not work).
ibtnExcel.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(), ".Images.excel.png");
2. I investigated further and found that I did not explicitly declare the image as WebResource in my assembly info . To get the embedded resource bit working, the following line is very important, and this solved my problem.

Place below line of code in "Assembly.Info" file.
[assembly: System.Web.UI.WebResource("MyControls.images.ferrari.jpg", "image/jpg")]