0

Can you please help with setting the title as page name not data from the widget in Sitefinity? I have tried

var urlName = SiteMapBase.GetActualCurrentNode().UrlName;
var pageHandler = this.ViewContext.HttpContext.Handler.GetPageHandler();
pageHandler.Title = urlName.ToUpperInvariant();
pageHandler.Page.Title = "MyTitle";

But it doesn't work. A version of Sitefinity 13.1.

Progman
  • 16,827
  • 6
  • 33
  • 48
John Vein
  • 3
  • 1

3 Answers3

0

At what stage of the page lifecycle are you setting it?

Most probably Sitefinity rewrites this after your code.

Your best bet is to place your code on PreRenderComplete event.

So, you know how you found the pageHandler - try subscribing to its PreRenderComplete event and in there set the Title of the page.

Veselin Vasilev
  • 3,698
  • 1
  • 15
  • 21
0

Do you just simply mean

ViewBag.Title = "My title";

In a controller action?

Steve McNiven-Scott
  • 1,770
  • 2
  • 15
  • 29
0

This works 12.2 but could not try 13.1

SiteMapBase.GetActualCurrentNode().Title

Dharman
  • 30,962
  • 25
  • 85
  • 135
user_vgizy
  • 125
  • 13