早上在看petshop里看到一个 PlaceHolder 的服务器控件,好象以前看教程什么都没有提过,今天查了下资料,看到了,就帖上来哦.以后有机会可以用的哦.
演示PlaceHolder控件(动态添加控件)
<% @ Page Language="C#" %>
<% @ Import Namespace="System.Data" %>
<Script Language="C#" Runat="Server">
public void Page_Load(Object src,EventArgs e)
{
Label lblTitle = new Label();
lblTitle.Text = "添加至PlaceHolder的Label控件";
holder.Controls.Add(lblTitle);
Button btnSubmit = new Button();
btnSubmit.Text = "添加的Button控件";
holder.Controls.Add(btnSubmit);
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
<b>演示PlaceHolder控件</b><br>
<asp:PlaceHolder id="holder" runat="server" />
</form>
</body>
</html>
本文介绍ASP.NET中的PlaceHolder控件,并通过实例演示如何动态添加控件到PlaceHolder中,包括Label和Button控件。
1546

被折叠的 条评论
为什么被折叠?



