asp.net技术内幕的书配源码
源代码在线查看: displayfeaturedproducttype.aspx
Src="FeaturedProduct1.ascx" %>
Src="FeaturedProduct2.ascx" %>
void Page_Load(object sender, EventArgs e) {
string strFeatured;
Random RanNum = new Random();
Control ctlControl=null;
switch(RanNum.Next(1,3)) {
case 1:
ctlControl = LoadControl("FeaturedProduct1.ascx");
((FeaturedProduct1)ctlControl).BackColor = "Yellow";
break;
case 2:
ctlControl = LoadControl("FeaturedProduct2.ascx");
((FeaturedProduct2)ctlControl).BackColor = "Yellow";
break;
}
if (ctlControl!=null)
plhFeatured.Controls.Add(ctlControl);
}
DisplayFeaturedProductType.aspx
id="plhFeatured"
Runat="Server" />