In this article we will discuss how to create custom welcome menu SharePoint 2010. Also you can check out my previous posts on:
Few days back I had one requirement where I do not need to show My Site link as well as I want to redirect My Profile link to a different page in the welcome link in SharePoint 2010. Though I am able to add one more link to the welcome menu, but I was not able to find a good article how to remove My profile link.
So what we have decided to do it is: we will go for a custom welcome link where we can have the name, my profile link that will go to a different page, Sign out and Sing in as different user link.
After that here is the .aspx code:
Welcome, <asp:PlaceHolder ID="placeHolderWelcomeName" runat="server"></asp:PlaceHolder>
<asp:HyperLink ID="hylnkMyProfile" runat="server" NavigateUrl= "~/_layouts/SharePointUserNameTest/mycustompage.aspx">My Profile</asp:HyperLink><br />
<asp:HyperLink ID="hylnkSignInDifferentUser" runat="server" NavigateUrl="<%$SPurl:~SiteCollection/_layouts/closeConnection.aspx?loginasanotheruser=true%>">Sign in as a Different User</asp:HyperLink><br />
<asp:HyperLink ID="hylnkSignOut" runat="server" NavigateUrl="<%$SPurl:~SiteCollection/_layouts/signout.aspx%>">Sign Out</asp:HyperLink>
And the .cs code:
protected void Page_PreRender(object sender, EventArgs e)
//Get the name
PostCacheSubstitutionText welcomeText = new PostCacheSubstitutionText();
welcomeText.TextType = PostCacheSubstitutionTextType.UserName;
Here in the above code we are getting the user name by the code.
As also you can see My Profile link is pointing to a different custom application page rather than to the existing My Profile page.
The 3rd hyperlink is the Sign in as a Different User link, You just need to call closeConnection.aspx page with a query string parameter as loginasanotheruser=true.
The 4th link is for Sign out which is reponsible for sign out and here we are calling the default SharePoint signout.aspx page.
Hope this will work for you also.