|
One would think that changing some text of a tab would be pretty trivial, especially since the ajax TabContainer control contains this function... set_headerText : function(value) { if (!this.get_isInitialized()) { throw Error.invalidOperation(String.format(AjaxControlToolkit.Resources.Tabs_PropertySetBeforeInitialization, 'headerText')); } if (this._headerText != value) { this._headerTab.innerHTML = value; this.raisePropertyChanged("headerText"); } } This function didn't work as simply as I had imagined
Through my testing I was getting various javascript errors as I tried random things. The most frustrating error I was receiving was 'Microsoft JScript runtime error: 'this._headerTab' is null or not an object'Why is this null or not an object. It shows up in the browser correctly and get_headerText returns the correct value!? Bypassing this function call was the only other option. This was achieved by the following javascript code $find('<%= TabContainer.ClientID %>').get_tabs()[0]._header.innerHTML = 'Changed'; Maybe the ajax tab.js file has an error and is setting the wrong property and instead of this._headerTab.innerHTML = value; it should be this._header.innerHTML = value; Below is the asp markup for the test and http://forums.asp.net/ a decent forum thread on a similiar topic.
<ajaxToolkit:TabContainer ID="TabContainer" runat="server" ActiveTabIndex="0" CssClass="ajax__tab_xp" EnableViewState="false"> <ajaxToolkit:TabPanel ID="Tab1" runat="server" HeaderText="Change ME"> <ContentTemplate>text </ContentTemplate> </ajaxToolkit:TabPanel> </ajaxToolkit:TabContainer> |