Set the page title in the asp file where it uses the main page

Ok, this is a weird way to do this, I know I had to do this on the_Load page on all pages when using Masterpage, but is there any way around this problem? I do not want to rearrange the pages, if I can help, if I can only insert a heading on <asp:content></asp:content>, it would be easier.

If someone stumbled upon this, or perhaps suggest a good way to do this, I know that jquery can do this document.title = '', but I heard that it is not SEO friendly.

Thanks!

+4
source share
3 answers

, MasterPage. : -

<%@ Page Title="Your Title" Language="C#" MasterPageFile="~/_masterpages/... etc

: -

protected override void OnLoad(EventArgs e)
{
    Page.Title = "Your Title";
    base.OnLoad(e);
}
+11

- ..

<asp:ContentPlaceHolder id="head" runat="server"> </asp:ContentPlaceHolder>

..

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title>  Your title goes here.  </title>
</asp:Content>
+6

simpler solution on the main page <%: Page.Title%> - here the title is the title

on the first page of the content page <% @ Page name = "Your name" Language = "C #" MasterPageFile = "~ / _masterpages / ... etc.

0
source

Source: https://habr.com/ru/post/1525724/


All Articles