简体   繁体   English

ASP.Net-AJAX控件工具包-动态添加和删除选项卡

[英]ASP.Net - AJAX Control Toolkit - Dynamically Add and Remove Tabs

I'm working on a project, converting a javascript based website into an ASP.Net and C# based website. 我正在一个项目中,将基于JavaScript的网站转换为基于ASP.Net和C#的网站。 I have several instances of hard coded AJAX Control Toolkit Tabs. 我有几个硬编码的AJAX控制工具包选项卡的实例。 I have to on page load, and on button click, add and remove tabs to these tab containers. 我必须在页面上加载,然后单击按钮,向这些选项卡容器添加和删除选项卡。

I've found many options to create the tabcontainer itself onload, and then add tabs and the html and so on. 我发现了很多选项,可以在onload时创建tabcontainer本身,然后添加选项卡和html等。 But is there any way in which I can access the hard coded Tab Container, and add and remove tabs to it? 但是,有什么方法可以访问硬编码的标签容器,以及向其中添加和删除标签?

I was thinking specifically, is there a C# equivalent to the Javascript getElementById() function? 我专门在想,是否有C#等效于Javascript getElementById()函数? Would it work in such a situation? 在这种情况下会起作用吗?

Discovered the answer. 发现了答案。

Reference your tabcontainer's id, for example if your tab container is hard coded with the id tabTabOne you would write. 引用您的tabcontainer的ID,例如,如果您的标签容器是使用您要编写的ID tabTabOne硬编码的。

tabTabOne.AutoPostBack = true;

AjaxControlToolkit.TabPanel t = new AjaxControlToolkit.TabPanel();
t.ID = "tabTabPanel3";
t.HeaderText = "Panel 3";
tabTabOne.Tabs.Add(t);

This will add a panel to the Container whose id you're using. 这会将一个面板添加到您正在使用其ID的Container中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM