1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Getting title of content pages programatically

Getting title of content pages programatically

6 posts, 0 answered
  1. Frank
    Frank avatar
    25 posts
    Registered:
    14 Jul 2008
    05 Jun 2009
    Link to this post
    I want to be able to add an "Email this page to a friend" link in a master page and I want the subject to be the title of the page. The problem I have is that it always sends the title of the master page as the subject. Is there a way for me to create a link that will send the title of the current page as the subject?

    Thanks.
  2. David
    David avatar
    22 posts
    Registered:
    04 May 2009
    05 Jun 2009
    Link to this post
    In VB.NET instead of

    Me.Title 

    try

    Me.Page.Title 


  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    06 Jun 2009
    Link to this post
    Hello Frank,

    Create a control and add the following loginc to it. This will return the current node title, so you can add the control to you master page.

        protected void Page_Load(object sender, EventArgs e)  
        {  
                CmsSiteMapNode node = SiteMap.CurrentNode as CmsSiteMapNode;  
                if(node !=null)  
                lbl1.Text = node.Title;  
     
        } 


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. WebGeek
    WebGeek avatar
    186 posts
    Registered:
    20 Dec 2006
    24 Feb 2010
    Link to this post
    I am using 3.7.2.

    Using the code below in my Masterpage I can access the Menu Label (under General) - but not the Title (Under Head Content). 

    protected override void OnPreRender(EventArgs e)
        {
            // Sets The Page Title
            CmsSiteMapNode node = SiteMap.CurrentNode as CmsSiteMapNode;    
            if (node != null)
            {
                Page.Title = node.Title + " - " + String.Format
               ("The Rest of my really long page title");
            }
            base.OnPreRender(e);
        }


    How can I access the Title property to modify it to include the rest of my Page Title once within the MasterPage?
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    24 Feb 2010
    Link to this post
    Hi medicalwebgeek,

    Page.Title - Gets or sets the title for the page when head runat="server"
    SiteMap.CurrentNode.Title - gets/sets the title of the SiteMapNode.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. WebGeek
    WebGeek avatar
    186 posts
    Registered:
    20 Dec 2006
    24 Feb 2010
    Link to this post
    I modified my code from

    Page.Title = node.Title

    to

    Page.Title = node.CmsPage.Title

    and got the results that I was looking for.

    Thanks.
Register for webinar
6 posts, 0 answered