ASP.Net/Asp Control/Placeholder — различия между версиями

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

Версия 15:30, 26 мая 2010

asp:placeholder control

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



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

<%@ 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);
      }
   }
}
--%>