Hello Telerik Team,
I referred this blog and was able to load UserControls dynamically from code-behind.
Even this blog shows how to close the tabs.
But, I would like to know how can I close the tabs if I create and tabs dynamically from code-behind.
Please help with a working code to this.
MyCode:
aspx:
This doesn't work for tabs instantiated from code-behind.
Thanks
I referred this blog and was able to load UserControls dynamically from code-behind.
Even this blog shows how to close the tabs.
But, I would like to know how can I close the tabs if I create and tabs dynamically from code-behind.
Please help with a working code to this.
MyCode:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
If Not Page.IsPostBack Then |
AddTab("Custom1") |
AddTab("Custom2") |
End If |
End Sub |
Private Sub AddTab(ByVal tabName As String) |
Dim tab As New RadTab() |
tab.Text = tabName |
RadTabStrip1.Tabs.Add(tab) |
Dim pageView As New RadPageView() |
pageView.ID = tabName |
RadMultiPage1.PageViews.Add(pageView) |
End Sub |
Protected Sub RadMultiPage1_PageViewCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMultiPageEventArgs) Handles RadMultiPage1.PageViewCreated |
Dim userControlName As String = e.PageView.ID + ".ascx" |
Dim userControl As Control = Page.LoadControl(userControlName) |
userControl.ID = e.PageView.ID + "_userControl" |
e.PageView.Controls.Add(userControl) |
End Sub |
<script type="text/javascript"> |
var tabStrip = $find("<%= RadTabStrip1.ClientID %>"); |
var multiPage = $find("<%= RadMultiPage1.ClientID %>"); |
var tab = tabStrip.findTabByText(tabText); |
var pageView = tab.get_pageView(); |
var tabtabToSelect = tab.get_nextTab(); |
if (!tabToSelect) |
tabtabToSelect = tab.get_previousTab(); |
tabStrip.get_tabs().remove(tab); |
multiPage.get_pageViews().remove(pageView); |
if (tabToSelect) |
tabToSelect.set_selected(true); |
</script> |
<telerik:RadTabStrip Style="position: absolute; top: 84px;" ID="RadTabStrip1" SelectedIndex="0" |
runat="server" MultiPageID="RadMultiPage1"> |
<TabTemplate> |
<%# DataBinder.Eval(Container, "Text") %> |
<img style="margin-left: 10px" src="img/close.png" alt="delete" onclick="deleteTab('<%# DataBinder.Eval(Container, "Text") %>')" /> |
</TabTemplate> |
</telerik:RadTabStrip> |
<telerik:RadMultiPage Style="position: absolute; top: 134px;" ID="RadMultiPage1" |
runat="server" SelectedIndex="0"> |
</telerik:RadMultiPage> |
</div> |
This doesn't work for tabs instantiated from code-behind.
Thanks