DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Different ways how to customize the MyLink in MOSS

Posted by PANVEGA on February 24, 2008

1. Add a hard coded link in the global links view.

  • Open MyLinks.ascx in an editor.
  • Add for e.g. a hyperlink into the column.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\MyLinks.ascx

<%@ Control className=”MyLinksUserControl” Language=”C#” Inherits=”Microsoft.SharePoint.Portal.WebControls.MyLinksUserControl,Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”OSRVWC” Namespace=”Microsoft.Office.Server.WebControls” Assembly=”Microsoft.Office.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SPSWC” Namespace=”Microsoft.SharePoint.Portal.WebControls” Assembly=”Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

<td class=”ms-globallinks”><SPSWC:MyLinksMenuControl id=”MyLinksMenu” runat=”server” /></td>
<td class=”ms-globallinks”><asp:Literal id=”hlMySiteSpacer” runat=”server” /></td>
<td class=”ms-globallinks”><a href=””>google</a></td&gt;

That’s it! Reset IIS and you’ll notice a brand new link in the global links section of your masterpage.

2. How to disable My Site or MyLinks in the Central Administration:

In order to turn off or disable the MySite or MyLinks functionality you need to be an Sharepoint administrator.

  • Go to the Central Administration Web Page. Click on the link for Shared Services Administration
  • If you have more than one SSP, select the one that is running the MySites functionality
  • Under “User Profiles and My Sites” click Personalization Services Permissions
  • Select the group you want to limit the functionality for.  More than likely you will just have NTAuthority\Authenticated Users.

In the next screen you will see a list of checkboxes,

  • To disable MySites uncheck “Create Personal Site”
  • To disable MyLinks uncheck “Use Personal Features”
  • Manage user profiles
  • Manage audiences
  • Manage permissions
  • Manage usage analytics

3. Make the MySite invisible in the MasterPage

But there is the “my site” shortcut on every page. To hide i had to go an every master page to change the webcontrol into : visible=”false” ; i had to do it even in the application.master.

In fact, there are still some way to reach the mysite page but not so easily. Anyway event if the user see the link, they ‘ll not be able to create a personnal site but receive an error message.

4. How to develop your custom MyLink Control in Visual Studio.

You’ll need following three things to achieve the goal

  • Customized version of MyLinksMenuControl class (MossSampleExtendedMyLinksMenuControl.cs)
  • SharePoint Delegate Control with control template (ExtendedMyLinks.ascx)
  • SharePoint feature to register Delegate Control

Create a new Custom Class

The OOTB My Links menu control is Microsoft.Office.Server.WebControls.MyLinksMenuControl. You’ll have to create a new user control which inherit from the OOTB one. And override the navigate URL of Manage Links with custom URL.

class LinksMenuControl : MyLinksMenuControl
protected override ArrayList LoadMenuItems()
ArrayList ar = base.LoadMenuItems();

MenuItemTemplate mtp = (MenuItemTemplate)(ar[ar.Count – 1]);
mtp.ClientOnClickNavigateUrl = SPContext.Current.Site.Url + “/_layouts/MyQuickLinks.aspx”;
mtp.ClientOnClickScript = “window.location='” + SPContext.Current.Site.Url + “/_layouts/MyQuickLinks.aspx'”;

ar.RemoveAt(ar.Count – 1);
return ar;

in this nice post you find the full solution:

Create a new Delegate Control

To use the control you created in Step 1. You have to create a new delegate control template to host this control. The OOTB one can be found in 12\TEMPLATE\CONTROLTEMPLATES\MyLinks.ascx

You can create a new .ascx file inside same or new directory and name it ExtendedMyLinks.ascx. In this example ExtendedMyLinks.ascx is created inside \CONTROLTEMPLATES\MossSample\.


<%@ Register Tagprefix=”SPSWC” Namespace=”Microsoft.SharePoint.Portal.WebControls” Assembly=”Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>

with your custom Assemply registration

<%@ Register Tagprefix=”SPSWC” Namespace=”YourControlClassNamespace” Assembly=”YourControlClassAssemblyName, Version=<version>, Culture=neutral, PublicKeyToken=<keyToken>” %>

in the code replace:

<SPSWC:MyLinksMenuControl id=”MyLinksMenu” runat=”server” />


<SPSWC:YourControlClassName id=”MyLinksMenu” runat=”server” />

Register your delegate control with a feature

You are a almost done. This last step is the most important step to get your control to override OOTB My Links control.

The OOTB control id and sequence number can be found in 12\TEMPLATE\FEATURES\MySite\MySiteFeatureElements.xml

Note: You can give your control the different ID. But if you do that, you also need to change master page’s DelegateControl with the new control ID. The default.master has this DelegateControl declaration for My Links menu

<SharePoint:DelegateControl ControlId=”GlobalSiteLink2 runat=”server”/></td>

Name it with “GlobalSIteLinks2” saves you the trouble of modify master page.

You need to create a SharePoint feature with feature metadata

Caution! You can not deploy the feature with Scope=”Site|Web”, this solution only works when Scope=”Farm”.  This is important because the DelegateControl in the MasterPage, here GlobalSiteLink2 applies to Scope Farm and the default MyLink.ascx Feature as well. An other deployment Scope is not possible (If I am not right, please send me your way how to cope with this issue).

When deploying on Farm Level you can only deploy the dll into the GAC rather than IIS bin folder. Your classes are not accessible from the bin folder when Scope is Farm.

<SharePoint:DelegateControl ControlId=”GlobalSiteLink2″ Scope=”Farm” runat=”server” Visible=”true”/></td>

follow my previous post how to create a delegate control feature:

I hope that helps you a little bit how to customize the MyLinks

more stuff:


One Response to “Different ways how to customize the MyLink in MOSS”

  1. Fred said

    Just a small correction, the menu control is found under Microsoft.SharePoint.Portal.WebControls.MyLinksUserControl and not into Office.Server as mentionned.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: