动态HtmlGenericControl类可以创建服务器端控件,以映射到相应的HTML元素,而不被.NET框架类所转换。比如<body><span>等。下面的例子就是利用HtmlGenericControl类动态创建Title元素的。
ChangePageTitle.aspx
<% Page Language="vb" AutoEventWireup="false" Codebehind="ChangePageTitle.aspx.vb"
Inherits="aspxWeb.mengxianhui.com.ChangePageTitle"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE ID="MyPageTitle" RUNAT="server"></TITLE>
<META NAME="CODE_LANGUAGE" CONTENT="Visual Basic 7.0">
<META NAME="vs_defaultClientScript" CONTENT="JavaScript">
<META NAME="vs_targetSchema" CONTENT="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<BODY MS_POSITIONING="GridLayout">
<FORM ID="Form1" METHOD="post" RUNAT="server">
</FORM>
</BODY>
</HTML>
ChangePageTitle.aspx.vb
Public Class ChangePageTitle
Inherits System.Web.UI.Page
Protected MyPageTitle As New HtmlGenericControl()
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
MyPageTitle.InnerText = "【孟宪会之精彩世界】之.NET开发者乐园"
End Sub
End Class
利用HtmlGenericControl类,动态改变Title文字
80酷酷网 80kuku.com