SharePoint Welcome Control Have you ever wanted to get rid of the Welcome text before the user name in the SharePoint user menu? At least I have! If you are like me - here is a solution that you can use to customize the text of the Welcome Control (Welcome.ascx).

The approach is pretty simple, and can be made in several ways, but I wanted a pretty clean solution that didn’t affect any other behavior of SharePoint and I wanted to write as little code as possible. Eventually I ended up with some more rows than expected, but this was due to the fact that I created this custom Welcome control configurable and deployable.

First of all some basics about the Welcome control. The Welcome.ascx control is a special control that handles the user menu, located top right (as standard) in your SharePoint site. The control has two states; one if the user is signed in and one when the user is not signed in. The Welcome.ascx control is located in the 12-folder under TEMPLATE\CONTROLTEMPLATES and uses the Microsoft.SharePoint.WebControls.Welcome control class in the Microsoft.SharePoint DLL file.

What I wanted to do was get rid of the Welcome text in front of the user name and only have the user’s name. To achieve this without recreating the whole control, I created a new class which derives from the Welcome control and changed the Welcome.ascx file to inherit from my new class instead.

  1: namespace ManagedWelcome {
  2:     public class Welcome : Microsoft.SharePoint.WebControls.Welcome {
  3:         protected Welcome() {
  4:         }
  5: 
  6:         [SharePointPermission(SecurityAction.Demand, ObjectModel = true)]
  7:         protected override void OnLoad(EventArgs e) {
  8:             base.OnLoad(e);
  9: 
 10:             if (HttpContext.Current.User.Identity.IsAuthenticated) {
 11:                 PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0] 
 12:                                                as PostCacheSubstitutionText;
 13:                 pt.TextType = PostCacheSubstitutionTextType.UserName;
 14:             }
 15:         }
 16:     }
 17: }

The original Welcome control consists of two objects; ExplicitLogout (of the type PersonalActions) and ExplicitLogin (of the type ApplicationPageLink). In line 13 I change the TextType property (enumeration of type PostCacheSubstitutionTextType) of the first control (which is of the type PostCacheSubstitutionText) in the ExplicitLogout object and set it to show only the user name (UserName enum value), default is the WelcomeUser value.

Now the Welcome control looks like this instead.

No Welcome text!

As always I cannot stop there so I made this into a customizable control, download below, which can be deployed to your web application. When activated, on Site Collection Features, it adds a link to the Site Collection Administration (not the best place, since the changes will affect the whole web application).

Site Collection Administration

When you click that link you will get to a Welcome Control administration page, where you can set the behavior of the Welcome control when a user is logged on or change the Sign In text.

Welcome Control admin

Using this feature you can on the fly change the behavior of the Welcome menu; have a custom Sign In text, change the welcome text to just the user name, the user login name, or e-mail and even the name of the Web.

Note: When installing this feature it will write over the default Welcome.ascx control, so make a backup of it first.

For full source download click here or just the solution package (WSP) click here.