在用户控件上创建公共属性:例如。
public bool ShowTab1 {get; set;}
public bool ShowTab2 {get; set;}
public bool ShowTab3 {get; set;}
public bool ShowTab4 {get; set;}
然后从 .aspx.cs 页面设置:
protected void Page_Load(object sender, System.EventArgs e)
{
usercontrol1.ShowTab1 = false;
usercontrol1.ShowTab2 = true;
usercontrol1.ShowTab3 = false;
usercontrol1.ShowTab4 = true;
}
使用该属性设置 UserControl 中的控件:
protected void Page_Load(object sender, System.EventArgs e)
{
Tab1.Visible = ShowTab1;
Tab2.Visible = ShowTab2;
Tab3.Visible = ShowTab3;
Tab4.Visible = ShowTab4;
}