ASP.Net/Asp Control/Placeholder
Версия от 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);
}
}
}
--%>