我已經(jīng)使用 jquery Tabs 小部件創(chuàng)建了一個頁面,如果我在 aspx 頁面上創(chuàng)建控件,它的工作方式就像教程一樣。但是,我現(xiàn)在需要從代碼生成這些控件(Div/UL/LI),以便我可以在單個頁面上多次重復(fù)(未知數(shù)量)......但 CSS 似乎不適用,并且該小部件不起作用。頁面.aspx:<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>頁面.aspx.cs:protected void Page_Load(object sender, EventArgs e) { accordion.ClientIDMode = ClientIDMode.Static; var divTabs = new HtmlGenericControl("div"); divTabs.ID = "tabs"; divTabs.ClientIDMode = ClientIDMode.Static; accordion.Controls.Add(divTabs); var ulMain = new HtmlGenericControl("ul"); divTabs.Controls.Add(ulMain); var il1 = new HtmlGenericControl("il"); il1.InnerHtml = "<a href=\"#tabs-1\">Tab 1</a>"; ulMain.Controls.Add(il1); var il2 = new HtmlGenericControl("il"); il2.InnerHtml = "<a href=\"#tabs-2\">Tab 2</a>"; ulMain.Controls.Add(il2); var divTab1 = new HtmlGenericControl("div"); divTab1.ID = "tabs-1"; divTab1.ClientIDMode = ClientIDMode.Static; divTabs.Controls.Add(divTab1); var parTag = new HtmlGenericControl("p"); divTab1.Controls.Add(parTag); var divTab2 = new HtmlGenericControl("div"); divTab2.ID = "tabs-2"; divTab2.ClientIDMode = ClientIDMode.Static; divTabs.Controls.Add(divTab2); var parTag2 = new HtmlGenericControl("p"); parTag2.ID = "parTab2"; divTab2.Controls.Add(parTag2); Label lbl1 = new Label(); Label lbl2 = new Label(); lbl1.Text = "HERE IS SECTION 1"; lbl2.Text = "HERE IS SECTION 2"; parTag.Controls.Add(lbl1); parTag2.Controls.Add(lbl2); }
1 回答

汪汪一只貓
TA貢獻(xiàn)1898條經(jīng)驗 獲得超8個贊
我不知道你是否必須更改 var il1 = new HtmlGenericControl("il"); var il1 = new HtmlGenericControl("li");
- 1 回答
- 0 關(guān)注
- 150 瀏覽
添加回答
舉報
0/150
提交
取消