/**//// <SUMMARY>
/// 获取或设置页的meta描述
/// </SUMMARY>
public string Meta_Description
{
get
{
return _description;
}
set
{
// 删掉多余的空格
// 译者注:\s匹配任何空白字符,包括空格、制表符、换页符等等。等价于 [\f\n\r\t\v]。
_description = Regex.Replace(value, "\\s+", " ");
}
}
}
VB
Imports System
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Text.RegularExpressions
'' 为了给内容页增加meta标签而扩展基类
Public Class BasePageClass BasePage
Inherits Page
Dim _keywords As String
Dim _description As String
'' 页将使用这个基类初始化
'' 增加一个Init的事件处理
Public Sub New()Sub New()
AddHandler Init, New EventHandler(AddressOf BasePage_Init)
End Sub
'' 页将使用这个基类初始化
'' 如果可用则增加meta关键字和meta描述
Sub BasePage_Init()Sub BasePage_Init(ByVal sender As Object, ByVal e As EventArgs)
If Not String.IsNullOrEmpty(Meta_Keywords) Then
Dim tag As HtmlMeta = New HtmlMeta()
tag.Name = "keywords"
tag.Content = Meta_Keywords
Header.Controls.Add(tag)
End If
If Not String.IsNullOrEmpty(Meta_Description) Then
Dim tag As HtmlMeta = New HtmlMeta()
&n