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'm trying to dynamically change the title of a SharePoint page via a web part on the page, but using Page.Title = "New Title" in my control yields no results, assuming that somewhere down the line SharePoint overrides my changes with default page title values.

Is this possible?

Basically, I have a component on the page with links. Clicking on any of these links will reload the current page with relevant data. The link clicked on should denote the page's title. I can achieve this with JavaScript once the page has finished loading, but would like to try a coding solution first.

share|improve this question
1  
I think you want to be using an SPFile object that's linked to the page in the pages document library to change things in SP. Page is the base ASP.NET class so many things don't work as you might expect. –  TZHX Aug 13 '12 at 11:02
add comment

2 Answers

up vote 1 down vote accepted

If you are looking to change the page title of a custom page, please try below

SPListItem item = SPContext.Current.ListItem;

if (item != null)
{
    item[SPBuiltInFieldId.Title] = <newTitle>;
    item.SystemUpdate(false); // this will make sure modified or modifiedby field is not updated
}

If you are trying to do by replacing the contentplaceholder, please check this,

http://blogs.perficient.com/microsoft/2007/08/programmatically-setting-a-web-part-pages-title/

share|improve this answer
add comment

Add in a content editor web part into your Web Part Page, edit the HTML source and add the below javascript.

<script type="text/javascript"> document.title = "Your Title Goes Here"; </script>

share|improve this answer
    
have a JS solution, just wanted to do it via code as stated above. thanks. –  JadedEric Aug 13 '12 at 11:14
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.