如何动态创建TabPanel [英] how to Create dynamically TabPanel

查看:63
本文介绍了如何动态创建TabPanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



要求我想动态创建Tabpanels我用下面代码来实现它



Hi every one

Requirement I want to create Tabpanels dynamically i used Below Code to achive it

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Temptab As AjaxControlToolkit.TabPanel

    Dim i As Integer = 0

    Dim lbl As Label
    For i = 1 To 5
        lbl = New Label
        lbl.Text = "Hi i m Tab no : " & i + 1

        Temptab = New AjaxControlToolkit.TabPanel()
        Temptab.ID = "NewTab" & TabContainer1.Tabs.Count + 1
        Temptab.HeaderText = "New Tab " & TabContainer1.Tabs.Count + 1
        Temptab.Controls.Add(lbl)

        TabContainer1.Tabs.Add(Temptab)


End Sub





这个Button1位于更新面板和标签容器中



问题当我点击按钮1时,此代码只添加一个tabpanel,在第二次点击之前创建的Tabpanel关闭,



i想要多个页面[aspx表单]应该在多个标签页面中打开[Not Browser标签我的标签控制器标签],



我知道回发这些控件的Dude正在丢失,但我无法创建所有动态创建的每次回发后控制因为我将获得大量的控制来创建和消耗时间。



我们是否有任何替代解决方案或其他控件或任何东西来实现我的功能



在此先感谢



this Button1 is inside the Update panel and Tab container too

Problem When ever i click Button one , this code adds only one tabpanel, on second click previously created Tabpanel goes off,

i want something like Multiple pages [aspx forms] should be opened in multiple tabs[Not Browser Tabs my tab controller tab],

I know Dude to post back these controls are losing but i cant create all dynamically created Controls after every postback cause i will get huge amount of controls to create and Time Consuming.

Do we have any alternative Solution or some other control or anything to achieve my functionality

Thanks In Advance.

推荐答案

这一行是您的问题。



This line is your problem.

Temptab = New AjaxControlToolkit.TabPanel()





你重新初始化每按一下按钮即可控制。这会清除标签。



标签控件应构建并包含在主页面加载中。



因此,在页面加载事件期间添加选项卡控件并对其进行初始化。



如果使用可见性 property。



这将在ASP.Net事件架构中正确注册控件。



然后当页面回发并重新加载时。 ASP.Net引擎可以使用 ViewState 来管理和重建控件的先前状态。



离开你只需要使其可见并在按钮事件中添加选项卡。



You reinitialise the control with each click of the button. This clears the tabs.

The tab control should be constructed and included within the main page load.

So add the tab control and initialise it during the page load event.

You can manage if it's rendered using the Visibility property.

This will register the control properly within the ASP.Net event architecture.

Then when the page posts back and reloads. ASP.Net engine can use the ViewState to manage and reconstruct the previous state of the control.

Leaving you only needing to make it visible and add the tab in your button event.


这篇关于如何动态创建TabPanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆