我有一个aspx页面,其中我使用PlaceHolder控件来包含动态创建的ajax tabconatiner,即选项卡容器中的选项卡的数量是在运行时基于某些数量决定的。每个选项卡依次加载ascx用户控件代码如下:
ASPX代码:
<asp:PlaceHolder ID="PC1" runat="server"></asp:PlaceHolder>
C#代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
createTab();
AddControl();
}
}
private void createTab()
{
try
{
tbcDynamic = new AjaxControlToolkit.TabContainer();
for (int i = 0; i < DOQuantity; i++)
{
int tabno = i;
TabPanel tbpanelProcessCategory = new TabPanel();
tbpanelProcessCategory.HeaderText = "BeneficiaryDetails" + " " + (i + 1);
tbpanelProcessCategory.ID = "Tab" + tabno.ToString();
//tbpanelProcessCategory.BorderStyle = 0;
tbpanelProcessCategory.Attributes["class"] = "ajax__tab_body";
tbcDynamic.Tabs.Add(tbpanelProcessCategory);
//tbpanelProcessCategory.Controls.Add()
}
}
private void AddControl()
{
try
{
for (int i = 0; i < DOQuantity; i++)
{
Control ctrlNombre = LoadControl("beneDetail.ascx");
tbcDynamic.Tabs[i].Controls.Add(ctrlNombre);
//tbcDynamic.Style.Add("border", "0");
}
if (!IsPostBack)
PC1.Controls.Add(tbcDynamic);
}
catch (Exception)
{
throw;
}
}
用户控制:
//Contains usual text boxes
抱歉格式不佳:(。