In ASP. NET programming, because a page is often used to display different content through different parameters, it is often necessary to dynamically output different HTML headers, such as title, keywords, descrtptions, etc.
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);
}