<script runat=server>
void Page_Load(Object sender , EventArgs e)
{
string strFeatured;
Random RanNum = new Random();
Control ctlControl;
strFeatured = "FeaturedProduct" + RanNum.Next( 1, 3 ) + ".ascx";
ctlControl = LoadControl( strFeatured );
plhFeatured.Controls.Add( ctlControl );
}
</Script>
<html>
<head><title>DisplayFeaturedProduct.aspx</title></head>
<body>
<div style=" height:100%; width:100%">
<div style=" padding-left:200px">
<asp:PlaceHolder
id="plhFeatured"
Runat="Server" />
</div>
</div>
</body>
</html>
PlaceHolder 一个容器可以放服务器控件和用户自定义控件
本文介绍了一种使用C#和ASP.NET动态加载特色产品用户控件的方法。通过随机选择不同的.ascx用户控件并将其放置在PlaceHolder中实现页面上特色产品的多样化展示。
1574

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



