locked
how can I get the PageTitle value programatically? RRS feed

  • Question

  • I have one control in the page as follows:

    <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>


    I want to know how can I get the PageTitle value programatically?


    Thanks.
    Friday, August 22, 2008 2:19 AM

Answers

  • Publishing pages are just items in a list (specifically a document library) so you get the title in the same way
    Brian Farnhill
    Microsoft Certified Professional
    http://pointstoshare.spaces.live.com
    • Marked as answer by Jake Wardley Monday, August 25, 2008 1:22 AM
    Saturday, August 23, 2008 12:32 AM
  • You should just be able to use this to get the title on to a page (taken from the out of the box defaultlayout.aspx in the master page gallery):

    <SharePoint:FieldValue id="PageTitle" FieldName="Title" runat="server" /> 

    Make sure that you have the SharePoint tag prefix registed at the top of the page for this to work.

    If you are trying to access the title programatically (with C# or VB.NE for example) then you need to get a reference to the SPListItem of the page, and then just use the title property of the item.


    Brian Farnhill
    Microsoft Certified Professional
    http://pointstoshare.spaces.live.com
    • Marked as answer by Jake Wardley Monday, August 25, 2008 12:58 PM
    Monday, August 25, 2008 2:00 AM

All replies

  • If this is for a publishing page? If so you can get to it as a property of the list item (so just SPListItem.Title)


    Brian Farnhill
    Microsoft Certified Professional
    http://pointstoshare.spaces.live.com
    Friday, August 22, 2008 5:54 AM
  • Hi, thanks for your answer,

    if it is a list ,you are right to get the title like that?

    How about getting the title of the publishing page?

    Thanks.
    Friday, August 22, 2008 12:19 PM
  • Publishing pages are just items in a list (specifically a document library) so you get the title in the same way
    Brian Farnhill
    Microsoft Certified Professional
    http://pointstoshare.spaces.live.com
    • Marked as answer by Jake Wardley Monday, August 25, 2008 1:22 AM
    Saturday, August 23, 2008 12:32 AM
  • Hi, thank for your answer,

    Can you give me the sample code to get the page title ?

    Is it possible for me to get the title value from SharePointWebControls:FieldValue control and how?

    Thanks in advance.
    Monday, August 25, 2008 1:55 AM
  • You should just be able to use this to get the title on to a page (taken from the out of the box defaultlayout.aspx in the master page gallery):

    <SharePoint:FieldValue id="PageTitle" FieldName="Title" runat="server" /> 

    Make sure that you have the SharePoint tag prefix registed at the top of the page for this to work.

    If you are trying to access the title programatically (with C# or VB.NE for example) then you need to get a reference to the SPListItem of the page, and then just use the title property of the item.


    Brian Farnhill
    Microsoft Certified Professional
    http://pointstoshare.spaces.live.com
    • Marked as answer by Jake Wardley Monday, August 25, 2008 12:58 PM
    Monday, August 25, 2008 2:00 AM