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?
Asked
Active
Viewed 135 times
2 Answers
1
I already find the answer here: https://sexycontent.codeplex.com/discussions/547134
@{
var page = (Page)HttpContext.Current.Handler;
page.Title = "Sample";
}

Jernej Pirc
- 504
- 1
- 4
- 13
1
this works, another option is to do it through JS
advantages
- future-compatible when dnn moves to mvc
- still google compliant
disadvantage
- not in the html for any external services which don't parse JS, like facebook

iJungleBoy
- 5,325
- 1
- 9
- 21
-
oh yes - that was just one of my sessions last week at the DNN Connect. Search for "2sxc translate" and you'll get a blog hit with a title. the blog itself adds the title in JS – iJungleBoy Jun 08 '16 at 05:50
-
I would definitely favor server-side for anything seo-relevant if you can do it without a ton of extra effort. Crawling source as delivered from a server is always going to be the easiest thing to do, Google changes their mind about stuff a lot, and they're not the only search engine. – Erik Reppen May 03 '17 at 19:40