Title of the current SiteMapNode doesn't appear

Posted by Community Admin on 04-Aug-2018 10:25

Title of the current SiteMapNode doesn't appear

All Replies

Posted by Community Admin on 13-Dec-2010 00:00

Hi all,


I've implemented custom control to show title of the page. Following code works in Beta 2 but property Title is empty for RC. Could you please provide correct way to get title of the page?

litTitle = container.GetControl<Literal>("litTitle", true);
SiteMapNode node = SiteMapBase.GetCurrentProvider().CurrentNode;
 
if (node != null)
    litTitle.Text = node.Title;

Posted by Community Admin on 13-Dec-2010 00:00

Hi Vitaly,

I checked the node.Title property in the RC and it is properly set.

Greetings,
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

Posted by Community Admin on 13-Dec-2010 00:00

Hi Ivan,


Thank you for your response. Unfortunately, I'm using this code in control which implemented in separated assembly. It doesn't work for me. Also, I've updated to last version of the SF 4 (4.0.992.0) without result.  
Please let me know if you have any ideas or questions. 

I can't attach video file (in swf format). I can send it directly by e-mail. 



Posted by Community Admin on 13-Dec-2010 00:00

Hi Vitaly,

Could you try using instance of PageNode which has a property Page.Title which is the name of the page.

var pageNode = _SiteMapNode asPageSiteNode;
var pn = man.GetPageNode(pageNode.Id);


Greetings,
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

Posted by Community Admin on 14-Dec-2010 00:00

Hi Ivan,


I found only one way to implement this feature. It's workaround but I hope it will be tested and fixed in next releases.
My code snippet:
litTitle = container.GetControl<Literal>("litTitle", true);
SiteMapNode node = SiteMapBase.GetCurrentProvider().CurrentNode;
 
if (node != null && node.ParentNode != null)
 
    foreach (SiteMapNode n in node.ParentNode.ChildNodes)
    
        if (n.Key == node.Key)
        
            litTitle.Text = n.Title;
            break;
        
    

Posted by Community Admin on 14-Dec-2010 00:00

Hi Vitaly,


I'm wondering if you've tried this approach? I came across it in another thread and it works well for me.

string title = new PageManager().GetPageNode(new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key)).Title;


Regards,
Phill

Edit: I should note that I use this in code behind of a usercontrol, so your scenario might be a bit different.

This thread is closed