首页  :: 订阅 订阅  :: 管理

HtmlGenericControl

Posted on 2005-04-22 09:38  GaoJie[高杰]  阅读(1328)  评论(0编辑  收藏  举报

Initializes a new instance of the HtmlGenericControl class.
Overload List
Initializes a new instance of the HtmlGenericControl class with default values.
[Visual Basic] Public Sub New()
[C#] public HtmlGenericControl();
[C++] public: HtmlGenericControl();
[JScript] public function HtmlGenericControl();
Initializes a new instance of the HtmlGenericControl class with the specified tag.
[Visual Basic] Public Sub New(String)
[C#] public HtmlGenericControl(string);
[C++] public: HtmlGenericControl(String*);
[JScript] public function HtmlGenericControl(String);
Example
[Visual Basic, C#] The following example demonstrates how to create a new instance of the HtmlGenericControl class using the overloaded constructor.
[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of the HtmlGenericControl constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic]

<%@ Page Language="VB" AutoEventWireup="True" %>

<html>

<head>

   <script runat="server">

      Sub Page_Load(sender as Object, 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>

</head>

<body>

   <form runat="server">

      <h3> HtmlGenericControl Constructor Example </h3>

      <asp:PlaceHolder ID="ControlContainer"
           runat="server"/>

   </form>

</body>
</html>
[C#]

<%@ Page Language="C#" AutoEventWireup="True" %>

<html>

<head>

   <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>

</head>

<body>

   <form runat="server">

      <h3> HtmlGenericControl Constructor Example </h3>

      <asp:PlaceHolder ID="ControlContainer"
           runat="server"/>

   </form>

</body>
</html>