HtmlGenericControl
生活随笔
收集整理的這篇文章主要介紹了
HtmlGenericControl
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
HtmlGenericControl 構造函數 (String)使用指定的標記初始化 HtmlGenericControl 類的新實例。命名空間: System.Web.UI.HtmlControls
程序集: System.Web(在 System.Web.dll 中)
語法Public Sub New ( _tag As String _
)public HtmlGenericControl(string tag)public:
HtmlGenericControl(String^ tag
)new : tag:string -> HtmlGenericControl參數tag類型:System..::.String要為其創建該類的此實例的元素的名稱。備注使用此構造函數創建并初始化使用指定標記的 HtmlGenericControl 類的新實例。 這使您可以動態創建不直接由 .NET Framework 類表示的任何 HTML 服務器控件元素。下表顯示 HtmlGenericControl 實例的初始屬性值。Property初始值TagNametag 參數的值。
注意注意如果 tag 參數為 nullNothingnullptrnull 引用(在 Visual Basic 中為 Nothing),則 TagName 屬性設置為 String..::.Empty。
示例下面的代碼示例演示如何使用重載構造函數創建 HtmlGenericControl 類的新實例。<%@ Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)' Create a new HtmlGenericControl.Dim NewControl As New HtmlGenericControl("div")' Set the properties of the new HtmlGenericControl control.NewControl.ID = "NewControl"NewControl.InnerHtml = "This is a dynamically created HTML server control."' Add the new HtmlGenericControl to the Controls collection of the' PlaceHolder control. ControlContainer.Controls.Add(NewControl)End Sub</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"><title>HtmlGenericControl Constructor Example</title>
</head>
<body><form id="form1" runat="server"><div><h3> HtmlGenericControl Constructor Example </h3><asp:PlaceHolder ID="ControlContainer"runat="server"/></div></form></body>
</html><%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">void Page_Load(Object sender, EventArgs e){// Create a new HtmlGenericControl.HtmlGenericControl NewControl = new HtmlGenericControl("div");// Set the properties of the new HtmlGenericControl control.NewControl.ID = "NewControl";NewControl.InnerHtml = "This is a dynamically created HTML server control.";// Add the new HtmlGenericControl to the Controls collection of the// PlaceHolder control. ControlContainer.Controls.Add(NewControl);}</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>HtmlGenericControl Constructor Example</title></head><body><form id="form1" runat="server"><div><h3> HtmlGenericControl Constructor Example </h3><asp:PlaceHolder ID="ControlContainer"runat="server"/></div></form></body></html>
轉載于:https://www.cnblogs.com/vmyspace/archive/2012/03/01/2375094.html
總結
以上是生活随笔為你收集整理的HtmlGenericControl的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【51单片机快速入门指南】8:看门狗定时
- 下一篇: wordpress实现搜索页关键词高亮