How to quickly and efficiently create the Head code section of the page

Source: Internet
Author: User
Tags control label

Generally, when we create a system
We have to write the same content for the Head part of every page. Is there a way for us to write the Head part into a control? Of course.

Let's write a class PageHead first.

Using System;
Using System. Web;
Using System. Web. UI;
Namespace
{
Public class PageHead: LiteralControl
{
Public PageHead ()
{
Base. Text = "<title>" + WebTitle + "-- Beibu Gulf News </title> \ n ";
Base. Text + = "<meta name = \" keywords \ "content = \" "+ WebKeywords +" \ "> \ n ";
Base. Text + = "<meta name = \" description \ "content = \" "+ WebDescription +" \ "> \ n ";
Base. Text + = "<meta name = \" author \ "content = \" tangyunle@163.com, QQ: 330611174 \ "/> \ n ";
Base. Text + = "<meta name = \" Copyright \ "content = \" kingeric | Tang yunle \ "/> \ n ";
Base. Text + = "<META HTTP-EQUIV = \" Content-Type \ "CONTENT = \" text/html; charset = gb2312 \ "> \ n ";
}

Private string _ webtitle;
Private string _ webkeywords;
Private string _ webdescription;

Public string WebTitle
{
Set {_ webtitle = value ;}
Get {return _ webtitle ;}
}
Public string WebKeywords
{
Set {_ webkeywords = value ;}
Get {return _ webkeywords ;}
}
Public string WebDescription
{
Set {_ webdescription = value ;}
Get {return _ webdescription ;}
}
}
}

In the HTML page, we can write

First, describe:
TagPrefix is the control label. For example, the current label is TT.
Namespace is the Namespace of the control.
Assembly is the Assembly name
<% @ Register TagPrefix = "TT" Namespace = "Namespace" Assembly = "TTStudio" %>

<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<HTML>
<HEAD>
<TT: PageHeadid = "PageHead1" runat = "server"/>
</HEAD>

You can.
Success!

========= Kingeric Original 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.