ASP.net 2.0 dynamically modify page keywords, headings, etc.

Source: Internet
Author: User

Asp.net2.0 new features, because often use a page through different parameters to display different content, so often need to achieve dynamic output of different htmlheader, such as title, keywords, Descrtptions,csslink,meta, icon and so on. The code is as follows:

protected void Page_Load (object sender, EventArgs e) {//page title page.title = "title";
        Encode/content type Htmlmeta Encode = new Htmlmeta (); Encode.
        HTTPEQUIV = "Content-type"; Encode.
        C
  
        PAGE.HEADER.CONTROLS.ADD (encode);
        Language Htmlmeta lang = new Htmlmeta (); Lang.
        HTTPEQUIV = "Content-language"; Lang.
        C
  
        Page.Header.Controls.Add (lang);
        Description Htmlmeta desc = new Htmlmeta (); Desc.
        Name = "Description"; Desc.
        C
  
        PAGE.HEADER.CONTROLS.ADD (DESC);
        Keyword Htmlmeta keywords = new Htmlmeta (); Keywords.
        Name = "keywords"; Keywords.
        Content = "asp.net, data access, asp.net control, AJAX, Ado.net,webserver";
  
        PAGE.HEADER.CONTROLS.ADD (keywords);
        Link/css Htmllink csslink = new Htmllink ();
        Csslink.href = "link Address";
        CSSLINK.ATTRIBUTES.ADD ("rel", "stylesheet"); CssLink.Attributes.Add ("TyPE "," Text/css ");
  
        PAGE.HEADER.CONTROLS.ADD (Csslink);
        Link/ico Htmllink icolink = new Htmllink ();
        Icolink.href = "/favicon.ico";
        ICOLINK.ATTRIBUTES.ADD ("rel", "shortcut Icon");
PAGE.HEADER.CONTROLS.ADD (Icolink); }

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.