Asp.net dynamic Title Keyword keywords description descrtptions

Source: Internet
Author: User

Method 1

If (! Ispostback)
{
// Page title
Page. Title = "my website title"; // you must set the webpage head tag to the server control mode, that is,

// Description webpage description
Htmlmeta DESC = new htmlmeta ();
Desc. Name = "Description ";
Desc. content = "my website description ";
Page. header. Controls. Add (DESC );

// Keyword webpage keyword
Htmlmeta KEYWORDS = new htmlmeta ();
Keywords. Name = "keywords ";
Keywords. content = "my website keywords ";
Page. header. Controls. Add (keywords );

}

Method 2 <Non-master page>
To optimize the search engine during webpage development, adding the Title Keyword description of the page is one of the most common methods. Asp.net MethodCodeAs follows:
Public void seo_head (String title, string keyword, string description)
{
Page. Title = title + "-My blog -";
Htmlmeta metakeywords = new htmlmeta ();
Htmlmeta metadeworkflow = new htmlmeta ();
Metakeywords. Name = "keywords ";
Metakeywords. content = keyword;
Metadeworkflow. Name = "Description ";
Metadeworkflow. content = description;
Header1.controls. Add (metakeywords );
Header1.controls. Add (metadegion); // header1 is the ID of the head
}

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

III others

The recommended method is 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);
}

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.