ASP. NET Master Page change content Page title Method

Source: Internet
Author: User
After the master page is defined, sometimes we need to change the title of the webpage. However, if we change the title attribute directly on the master page, the same title may occur on other content pages, VS2008 provides new features for the master page.
1. Use the Title attribute in the Page command on the Content Page to change the title of the Content Page:
<% @ Page Language = "C #" MasterPageFile = "~ /MyMaster. master "Title =" My Title "%>

2. Change through programming: The premise is that the Void Page_Load ()
{
......
Page. Header. Title = "My Title ";
......
}

3. Through the head placeholder control of the content page, the master page added in VS2008 will have the following content placeholder asp: ContentPlaceHolder control in the header (drag the title label of the master page to the control)
<Asp: ContentPlaceHolder id = "head" runat = "server">
<Title> No title page </title>
</Asp: ContentPlaceHolder>
On the Content page, a corresponding asp: Content control is often added. You only need to change the title label Content.
<Asp: Content ID = "Content1" ContentPlaceHolderID = "head" Runat = "Server">
<Title> my title </title>
</Asp: Content>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.