Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a server control and want to place it in the person.aspx page on the My Site however do not want to edit the page through SharePoint Designer but want to edit the file itself from the file system (on the WFE). Where can i find the person.aspx on the WFE?

Update

Now, I understand that we should not edit the SharePoint default pages. So I would like to insert my server control into the person.aspx page without really editing the file itself.

As of now, I have updated the person.aspx (from the site definition) page with the below entries

<% Register TagPrefix="my" Namespace="myControl.demo.Controls" 
Assembly="myControl.demo.Controls, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=4b179e608e5a0adf" %>

and added the below entry under the "PlaceHolderMain" section:

<my:MyControl ID="MyControl" runat="server"
LabeltoPropertyPair="Some Value :$Value to replace: ,"/>

however would like to do the same without really editing the page itself? How it can be achieved? should I need to use Feature stapling (I do not have any knowledge)?

share|improve this question
    
Can you provide some more info? What SharePoint version? Where exactly should your custom WebControl be placed? –  Sig Weber Aug 18 '11 at 7:22
    
I found the file "person.aspx" located under the folder - C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\SiteTemplates\SPSMSITEHOST". Basically, My server control is a dll and placed in the GAC. –  Karthikeyan Aug 18 '11 at 11:59
    
I meant where your control should appear on the person.aspx page ;-) –  Sig Weber Aug 18 '11 at 12:55
add comment

2 Answers

up vote 6 down vote accepted

You should not edit the person.aspx in the file system (updates will likely overwrite it).

SharePoint Designer is the first option, but not a good one. It will customize the page and you will not benefit from pre-compilation, and can cause headaches when upgrading!

One approach that I've previously uses is to add a new feature that puts a control in the AdditionalPageHeaders delegate control. This control is present on all pages. In that control I check the name/url of the page. In this case if it finds person.aspx then redirect to your custom page (custom-person.aspx). The custom page is the modified person.aspx page deployed to the _layouts folder.

share|improve this answer
    
ok, I have verified this and works like a champ, thanks. However, would like to ensure there won't any issue if we use our user control for the delegation control - additionalpagehead. –  Karthikeyan Aug 19 '11 at 17:22
    
You could basically put whatever you want in that control... –  Wictor Wilen MCA MCM MVP Aug 19 '11 at 17:52
    
awesome..It works perfectly. any suggestion on AllowMultipleControls property of the delegation control and how to set "true" to the property AllowMultipleControls of the delegation control - AdditionalPageHeaders. –  Karthikeyan Aug 20 '11 at 13:12
add comment

Another option is to create your own version of person.aspx and include it in a deployable feature that deploys the file to the rootfolder of the rootweb of the MySiteHost. Then, inside a feature receiver, get a reference to the newly deployed file using the SPWeb.Files collection and perform a "MoveTo" operation on it - over the original person.aspx.

Here are a couple methods for applying a custom file to the rootweb, and reverting back. These methods depend on renaming the original file to something else in order to revert back if needed:

  private void ApplyCustomRootFile(string originalFilename, string newFileName, string newNameForOriginalFile)
    {
        SPFileCollection files = Site.RootWeb.Files;
        SPFile originalFile = files[originalFilename];
        originalFile.CopyTo(newNameForOriginalFile, false);

        SPFile newDefaultFile = files[newFileName];
        newDefaultFile.MoveTo(originalFilename, true);
    }
    private void RevertCustomRootFile(string originalFilename, string newNameForOriginalFile)
    {
        SPFileCollection files = Site.RootWeb.Files;
        SPFile originalFile = files[newNameForOriginalFile];
        originalFile.MoveTo(originalFilename, true);
    }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.