Login

Redirect to your own MySite Landing Page


Have you ever wanted to redirect a user to your own MySite landing page.  It is very easy to do with a single delegate control.  This will allow your SharePoint sites to have a profile page such as MyDevCow at any location in the site.  This code would run when you click the persons profile and click My Settings

mysettings

First create a user control with nothing on the page.  Something like the following

<%@ Control Language="C#" Inherits="DevCow.SharePoint.Controls.DevCowUserProfileRedirect,DevCow.SharePoint,Version=1.0.0.0,Culture=neutral,PublicKeyToken= 0528d6137835b00a" %>

Now create the code behind for a user control that receives a userprofile from the user information list.

public class DevCowUserProfileRedirect : UserControl, IFormDelegateControlSource
{
    #region IFormDelegateControlSource Members

    public void OnFormInit(object objOfInterest)
    {
        SPListItem user = objOfInterest as SPListItem;
        if (user != null)
        {
            this.RedirectIfNecessary(user);
        }

    }

    private void RedirectIfNecessary(SPListItem user)
    {
        //Redirect to hard coded site
        SPUtility.Redirect("http://sharepoint.devcow.com/Pages/DevCowProfile.aspx", SPRedirectFlags.Default, this.Context);
    }

    public void OnFormSave(object objOfInterest)
    {
    }

    #endregion
}

Finally create a Feature with an elements manifest that has the delegate control lower than 100.  Make sure to use the ID of ProfileRedirection

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Control Id="ProfileRedirection" Sequence="50" ControlSrc="~/_controltemplates/DevCow/DevCowMySiteRedirection.ascx"/>
</Elements>

Digg It!  StumbleUpon  Reddit  Del.icio.us  NewsVine  Furl  BlinkList  Ma.gnolia  Technorati

» Trackback URL to this Post

http://sharepointguys.com/brendon/trackback.ashx?id=20

Comments

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

» Trackbacks & Pingbacks

  1. Pingback from Links (6/17/2008) « Steve Pietrek - Everything SharePoint