ASP.Net/Asp Control/Placeholder

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

asp:placeholder control

   <source lang="csharp">

<%@ Page Language="vb" %> <html> <head>

  <title>Programmatic Control Example</title>
  <script runat="server">
     Sub Page_Init()
        Dim Message As New Literal()
        Message.Text = "This text set from Page_Load!"
        PH.Controls.Add(Message)
     End Sub
  </script>

</head> <body>

  <form runat="server">
     <asp:placeholder id="PH" runat="server"/>
  </form>

</body> </html>

      </source>
   
  


Deal with asp:placeholder control from code behind (C#)

   <source lang="csharp">

<%@ Page Language="c#" src="ProgControl_cb.cs" Inherits="MyNamespace.ProgControl" %> <html> <head>

  <title>Programmatic Control Example using Code-behind</title>

</head> <body>

  <form runat="server">
     <asp:placeholder id="PH" runat="server"/>
  </form>

</body> </html>

<%-- using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace MyNamespace {

  public class ProgControl:Page
  {
     protected PlaceHolder PH = new PlaceHolder();
     void Page_Load()
     {
        // The placement of the Placeholder control 
        //   determines where output appears
        Literal Message = new Literal();
        Message.Text = "This text set from Page_Load!";
        PH.Controls.Add(Message);
     }
  }

} --%>

      </source>