Hi,
I have created application where tabs are generating dynamically. When I am trying to delete those tabs with cross bar I am getting error like undefined tabs. Can any one solve this issue. I am getting error in javascript code. I can delete tabs with button click event. But I am unable to delete the code with crossbar. The Issue is in
the text value is not binding there. How to bind the dynamically generating text value.
I have created application where tabs are generating dynamically. When I am trying to delete those tabs with cross bar I am getting error like undefined tabs. Can any one solve this issue. I am getting error in javascript code. I can delete tabs with button click event. But I am unable to delete the code with crossbar. The Issue is in
<%# DataBinder.Eval(Container, "Text") %> |
the text value is not binding there. How to bind the dynamically generating text value.
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!Page.IsPostBack) |
{ |
RadTab tab = new RadTab(); |
tab.Text = string.Format("New Page {0}", 1); |
RadTabStrip1.Tabs.Add(tab); |
RadPageView pageView = new RadPageView(); |
pageView.Height = new Unit("50px"); |
pageView.Width = new Unit("1300px"); |
RadMultiPage1.PageViews.Add(pageView); |
BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count); |
RadTabStrip1.SelectedIndex = 0; |
} |
} |
private void BuildPageViewContents(RadPageView pageView, int index) |
{ |
pageView.ID = "Page " + index.ToString(); |
pageView.Controls.Add(new LiteralControl(" <B>New page</B>" + (index).ToString())); |
} |
protected void Button1_Click(object sender, EventArgs e) |
{ |
RadTab tab = new RadTab(); |
tab.Text = string.Format("New Page {0}", RadTabStrip1.Tabs.Count + 1); |
RadTabStrip1.ID = "Tab " + RadTabStrip1.Tabs.Count; |
RadTabStrip1.Tabs.Add(tab); |
RadPageView pageView = new RadPageView(); |
pageView.ID = "Page " + pageView.Index.ToString(); |
RadMultiPage1.ID = "page" + pageView.Index.ToString(); |
RadMultiPage1.PageViews.Add(pageView); |
BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count); |
RadTabStrip1RadTabStrip1.SelectedIndex = RadTabStrip1.SelectedIndex + 1; |
RadMultiPage1.SelectedIndex = RadTabStrip1.SelectedIndex; |
} |
.aspx |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RadTab.aspx.cs" Inherits="Default" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title></title> |
<telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
<Scripts> |
<%--Needed for JavaScript IntelliSense in VS2010--%> |
<%--For VS2008 replace RadScriptManager with ScriptManager--%> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> |
</Scripts> |
</telerik:RadScriptManager> |
<script type="text/javascript"> |
/* <![CDATA[ */ |
function deleteTab(tabText) |
{ |
var tabStrip = $find("<%= RadTabStrip1.ClientID %>"); |
var multiPage = $find("<%= RadMultiPage1.ClientID %>"); |
var tab = tabStrip.findTabByText(tab.toString()); |
// if (tab != null) |
// { |
// alert(tab.toString()); |
// } |
// else alert(" TAB IS NULL "); |
var pageView = tab.get_pageView(); |
var tabToSelect = tab.get_nextTab(); |
if (!tabToSelect) |
tabToSelect = tab.get_previousTab(); |
tabStrip.get_tabs().remove(tab); |
multiPage.get_pageViews().remove(pageView); |
if (tabToSelect) |
tabToSelect.set_selected(true); |
} |
/* ]]> */ |
</script> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
</telerik:RadAjaxManager> |
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" Height="50px" SelectedIndex="0" Width="1300px" MultiPageID="RadMultiPage1"> |
<TabTemplate> |
<%# DataBinder.Eval(Container, "Text") %> |
<img style="margin-left: 50px" src="delete.gif" alt="delete" onclick="deleteTab('<%# DataBinder.Eval(Container, "Text") %>')" /> |
</TabTemplate> |
</telerik:RadTabStrip> |
<div> |
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add Tab" /> |
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Delete Tab" /> |
</div> |
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" |
Height="320px" Width="700px" BorderStyle="Solid" OnPageViewItemCreated="RadMultiPage1_PageViewItemCreated1"> |
</telerik:RadMultiPage> |
</form> |
</body> |
</html> |