Looking at the documentation, there is no clear way that I see to delete/remove a tab. There are addTab, addCopy, moveTab, etc... but no deleteTab or removeTab or even closeTab.
I need to completely delete a tab. Has anyone seen a way to do this client-side?
Hi, Revbones.
It's seems that the WebTab API don't have such client-side functionality. I suppose there is a reason for this so I will investigate it and will inform you.
Meanwhile I can suggest you workaround for this. You can hide the tabs on the client, those you want to delete, and on the server to check all the hidden tabs and delete them from the tabs collection.
var webTab = $find("<%=WebTab1.ClientID%>"),
tab = webTab.getTabAt(0);
tab.set_hidden(true);
I hope this will help you.
Thanks,Nikolay
Unfortunately hiding tabs won't work for me. I'm loading data via client side templates and feel fairly certain that after a while of creating and hiding tabs that I'll start to run into trouble.
Hi DK,
Thank you for a sample.
I could not reproduce exception on first cycle of add/remove, but it was raised when I repeated add/delete few times.The problem happens because contents of tabs have default values of IDs. The default values of templated-child-control IDs in naming-container (template) are generated by server and they appear like tmpl0, tmpl1, tmpl2, etc. When you removed tabs and keep old tabs saved (in session or similar), then there is a chance that autogenerated value of ID will be the same as ID of saved control. That situation triggers exception when server checks if controls are valid (to protect against problems with events view state actions).2 or more controls with same IDs are not exceptable.
I suggest to build logic, which ensures that child controls of each newly created tab have unique IDs. In that speceific sample, each tab has dynamic UserControlUrl. So, at the time of creation, an application may verify that the ID of that control is valid (explicitly defined) and if it is not, then set it to custom/unique value. The easiest way is to create a static counter, which will help build unique values for IDs.Check logic may include test for expected value/prefix or check for default "tmpl" prefix (last one can be dependant on specific version of server and can be unreliable).If application has mixed aspx-tabs, ContentUrl tabs, dynamic-not-UserControlUrl tabs, then "check" logic should be adjusted for that. Idea, is to ensure that all IDs of dynamic controls are unique.
Below is an example:
private object CreateWebTabDynamically(){ ... webTab.Tabs.Add(tab); this.FixID(tab); ...}protected void AddTab(object sender, EventArgs e){ ... webTab.Tabs.Add(tab); this.FixID(tab); ...}
private static int _id = 0;private void FixID(Control tab){ Control user = tab.HasControls() ? tab.Controls[0] : null; // here can be a better validation for dynamic user control if (user == null) return; string id = user.ID; if (string.IsNullOrEmpty(id) || id.IndexOf("tabID") < 0) //if (string.IsNullOrEmpty(id) || id.IndexOf("tmp") >= 0) user.ID = "tabID" + _id++;}
HI V,
I added this FixID method in the sample application I had send to you and it was giving still same JScript error. I happens if you open three tab and close the center one i.e., Tab0 Tab1 and Tab2. If you try to close Tab1 you can see that JScript.
Thanks for immediate response
Dk
Hi Dk,
I could not reproduce JScript error on the first attempt to remove 2nd tab, but only after repeating add/remove actions few times. Last time I tested your codes with asp:ScriptManager. Today I added reference to AjaxControlToolkit and replaced ScriptManager with asp:ToolkitScriptManger.
Both cases worked exactly same way and exception was raised in MicrosoftAjaxWebForms.debug.js.
Under ScriptManager it was at the end of
function Sys$WebForms$PageRequestManager$_endPostBack(error, executor, data) {...}
and in case of ToolkitScriptManager it was at the end of a similar function
_endPostBack: function PageRequestManager$_endPostBack(error, executor, data) {...}
I tested sample within a website of VisualStudio2008. AjaxControlToolkit.dll: 11/16/2011, File Version: 3.5.51116.0.
Maybe there is something else is different in our samples, or there are different versions of AjaxControlToolkit.
I upgraded my AjaxControlToolkit dll but still getting same issue. I am sending you my sample code with your changes again. And I am also running this in VisualStudio2008
Thanks,
I retested sample with same results.
I noticed that your sample uses old Infragistics35.Web.v10.2.dll. I think that is the reason why I could not reproduce that. The earliest dll on my machine is Infragistics35.Web.v11.1.
I looked at history in tfs to complare some source files and found some differences, which may affect that scenario. For example, the newer versions of WebTab force instantiation of templates at run time within OnInit event. Older version waited for CreateChildControls or OnPreRender/Render.
I suggest you to upgrade NetAdvantage to more recent version.
Ok I got it working with the latest Service Release of Infragistics35.Web.v11.2 version Version=11.2.20112.2159,
and also Infragistics35.Web.v12.1 with latest service release Version=12.1.20121.2048.
Hi VK,
I was on vacation and could not reply you earlier. Actually I tried my sample application with Infragistics35.Web.v12.1, Version=12.1.20121.1005 and I am getting exactly same behaviour.
Appreciate your help!
I built debug dll for version 11.2.20112.1019 and reproduced exception, which you referred to.
Please, get latest service release for NetAdvantage.
We have license for Infragistic dll 11.2 dll and its version is 11.2.20112.1019.
About AjaxControlToolkit , I was using old version earlier and was facing similar issue. Upgrading to latest version did not help at all.
Thanks for prompt responses,
I cannot give my personal email, maybe there are some other options to down load large attachement. I can consult developer support about that.
I assume that you have latest version of 11.2 dll, which is 11.2.20112.2159 or 11.2.20112.2141. Those versions should be ok. If you have earlier version, then please give me its exact version. (You may look at File version within Details of dll Properties).I could try to find its date in tfs history, gets all files for that date and build debug dll from them. Though, I would like to avoid similar.That is possible that there are other changes in codes of WebTab (besides InstantiateTemplates within OnInit), which make difference for your application.
The best choice is to use the most recent available service release.
To exclude possible issue with version of AjaxControlToolkit, you may replace it in your sample by ScriptManager and check if it makes any difference.