Sdílet prostřednictvím


SharePoint : Top Area Navigation Drop Down Menu Control

This menu control works based on external JavaScript and CSS file. These files are sample only. Follow the following steps to install the web control into the page.

Step 1: Create Web Control (I know you know all these steps, but just adding bit…)

  • Open Visual Studio.net

  • Create New Visual C# Web Control Library Project.

  • Name the project as AreaMenuControl

  • Rename the WebControlLibrary1.cs as MyAreamenuControl.cs

  • Copy and paste the code from the MyAreamenuContro.cs.txt file attached here in the MyAreamenuControl.cs file

  • Copy the AreaMenuControl.snk file attached here into project folder

  • Open the AssemblyInfo.cs file.

  • Specify the AssemblyKeyFile as “..\\..\\AreaMenuControl.snk”

  • Compile the project

Step 2: Install the web control into GAC

  • Goto Start->Administrative Tools->Microsoft .NET Framework 1.1 Configuration

  • Right click the “Assembly Cache” tree node and clik Add

  • Select the AreaMenuControl.dll and click Open

Step 3: Copy additional files into corresponding folders

  • Copy the menu.js and menu.css file into “C:\program files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\1033“ folder

  • Create a folder “img” in “C:\program files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\1033”

  • Copy lev0_bg1.gif, lev0_bg2.gif and lev1_arrow.gif into “C:\program files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE \LAYOUTS\1033\img” folder

Step 4: Insert the menu into aspx pages

  • Open aspx page where you want to insert the menu. (For example default.aspx pages in SPS, SPSTopic, SPSToc and all other files)

  • Copy and paste the following line at the top of the page

<%@ Register Tagprefix="AreaMenuControl" Namespace="AreaMenuControl" Assembly="AreaMenuControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5539eabbaefd0c86" %>

  • Copy and paste the following lines into the <head> tag

<script language="JavaScript" src="src="/_layouts/<%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%>/menu.js"></script>

<link rel="stylesheet" href="/_layouts/<%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%>/menu.css">

  • Copy and paste the following line where ever you want to insert menu

<AreaMenuControl:MyAreaMenuControl ID="MyAreaMenuControl1" runat="server"/>

For example if you want to place at the top of the default.aspx page then insert the following line after the first <table> tag in the body tag

<tr> <td colspan="3" width="100%" height="24" bgcolor="#2C5F93">

<AreaMenuControl:MyAreaMenuControl ID="MyAreaMenuControl1" runat="server"/>

</td> </tr>

Step 5: Web.config file settings.

  • Open the web.config file and add the following <safe control> entry

            <SafeControl Assembly="AreaMenuControl, Version=1.0.0.0, Culture=neutral,PublicKeyToken=5539eabbaefd0c86" Namespace="AreaMenuControl" TypeName="*" />

Note :

All the code attached here is sample only and they have been provided as of is

I have modified the code slightly to arrange the areas as per its Order Use the MyAreaMenuControl_WithSortedOrder.Cs file instead of MyAreaMenucontrol.cs.

MyAreaMenuControl.zip

Comments

  • Anonymous
    March 21, 2006
    Hi Karthick  

    its a wonderful effort by you, but I am getting the following error please advice me... I am using a different system to compile the .dll files will they make any difference

    I am getting the following error please advice
    thanks
     The page contains server script, which is not supported on this server.

    Web Parts Maintenance Page: If you have permission, you can use this page to temporarily disable Web Parts or remove personal settings. For more information, contact your site administrator.

    Ram
     
  • Anonymous
    March 30, 2006
    The comment has been removed
  • Anonymous
    April 06, 2006
    Thanks Karthick!  This is just what I needed!  I am having one problem though, the nav allows users to see areas they do not have access to.  I have been trying to find out how to fix this all day with no luck.  Do you have any ideas?
  • Anonymous
    May 11, 2006
    Might be a service pack isssue, if SP1 is used.  See

    http://geekswithblogs.net/marcost/archive/2006/03/16/72493.aspx

  • Anonymous
    August 11, 2006
    Excellent Nav control......I also created one for download that does areas and top level team sites.  If anyone is interested see www.sharepointbranding/customnavigation

    Thanks,
    Dan