Jernej Pirc
Jernej Pirc

Reputation: 514

Set page title from 2sxc dnn module

How can I change page title from module razor code? I have news module on page site.name/news, and it is called with news id eg.: site.name/news/newid In this page I display different news and I also want to set different html title for each of this pages. How can I do this?

Upvotes: 1

Views: 162

Answers (2)

iJungleBoy
iJungleBoy

Reputation: 5638

this works, another option is to do it through JS

advantages

  1. future-compatible when dnn moves to mvc
  2. still google compliant

disadvantage

  1. not in the html for any external services which don't parse JS, like facebook

Upvotes: 1

Jernej Pirc
Jernej Pirc

Reputation: 514

I already find the answer here: https://sexycontent.codeplex.com/discussions/547134

@{
    var page = (Page)HttpContext.Current.Handler;
    page.Title = "Sample";
}

Upvotes: 1

Related Questions