(ext.) ASP. Dynamic Settings Header title Title Keyword Keywords Description descrtptions

Source: Internet
Author: User

Method One

if (! IsPostBack)
{
Page title
Page.title = "My site title";//the page head tag must be set to the server control mode, that is

Description page description
Htmlmeta desc = new Htmlmeta ();
Desc. Name = "Description";
Desc. Content = "Description of my Site";
PAGE.HEADER.CONTROLS.ADD (DESC);

Keyword page keywords
Htmlmeta keywords = new Htmlmeta ();
Keywords. Name = "keywords";
Keywords. Content = "My Site keywords";
PAGE.HEADER.CONTROLS.ADD (keywords);

}





Method two < non-master pages under >
In the development of Web pages for search engine optimization, add the page title keyword description is one of the most commonly used methods. The method code for the ASP. NET is as follows:
public void Seo_head (string title, string keyword, string description)
{
Page.title = Title + "-my blog-";
Htmlmeta metakeywords = new Htmlmeta ();
Htmlmeta metadescription = new Htmlmeta ();
Metakeywords.name = "Keywords";
metakeywords.content = keyword;
Metadescription.name = "description";
metadescription.content = description;
HEADER1.CONTROLS.ADD (metakeywords);
HEADER1.CONTROLS.ADD (metadescription);//header1 is the head ID.
}

---------Delete the title tag of the content page if there is no master page----------



Three other

The recommended simple practices are as follows:

protected void Page_Load (object sender, EventArgs e)
{
Page Title
Page.title = "This is a Title and Meta test page.";

Encode/content type
Htmlmeta encode = new Htmlmeta ();
Encode. HTTPEQUIV = "Content-type";
Encode. Content = "text/html; Charset=utf-8 ";
PAGE.HEADER.CONTROLS.ADD (encode);

Language
Htmlmeta lang = new Htmlmeta ();
Lang. HTTPEQUIV = "Content-language";
Lang. Content = "ZH-CN";
Page.Header.Controls.Add (lang);

Description
Htmlmeta desc = new Htmlmeta ();
Desc. Name = "Description";
Desc. Content = "Test the meta controls";
PAGE.HEADER.CONTROLS.ADD (DESC);

Keyword
Htmlmeta keywords = new Htmlmeta ();
Keywords. Name = "keywords";
Keywords. Content = "Title,meta,test,page";
PAGE.HEADER.CONTROLS.ADD (keywords);

Link/css
Htmllink Csslink = new Htmllink ();
Csslink.href = "Masterpage.css";
CSSLINK.ATTRIBUTES.ADD ("rel", "stylesheet");
CSSLINK.ATTRIBUTES.ADD ("type", "text/css");
PAGE.HEADER.CONTROLS.ADD (Csslink);
}

(ext.) ASP. Dynamic Settings Header title Title Keyword Keywords Description descrtptions

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.