Sunday, March 11, 2012

tabcontrol - owner must be set before initialize

Hello Kevin,

I was having the same problem trying to update webcontrols on my masterpage. Sometimes it works and sometimes not.

The problem was when i places the Scriptmanager at the bottom of my masterpage it was not loaded before the controls using the scriptmanager.So i moved it to the top of the page and viola, now it worked fine!

Please reply if it works or not.

Best Regards Kristian


Thanks for that. I was thinking it was something to do with timing or loading. However my scriptmanager is at the start of the master page, right after the form tag.

Hello, I got the same error you were having. I found out it was because I added the same tab twice by accident. See lines 6 and 13. Did you solve your problem?

1AjaxControlToolkit.TabPanel tabAdminPrimes =new AjaxControlToolkit.TabPanel();2modules_modAdminPrimes modAdminPrimes = (modules_modAdminPrimes)this.LoadControl("modules/modAdminPrimes.ascx");3tabAdminPrimes.HeaderText ="nVision Primes";4tabAdminPrimes.ID ="2";5tabAdminPrimes.Controls.Add(modAdminPrimes);6tcMain.Tabs.Add(tabAdminPrimes);78AjaxControlToolkit.TabPanel tabAdminTeams =new AjaxControlToolkit.TabPanel();9modules_modAdminTeams modAdminTeams = (modules_modAdminTeams)this.LoadControl("modules/modAdminTeams.ascx");10tabAdminTeams.HeaderText ="Teams";11tabAdminTeams.ID ="3";12tabAdminTeams.Controls.Add(modAdminTeams);13tcMain.Tabs.Add(tabAdminPrimes);
This may or may not help.

Hi, i'm getting the same problem "Owner must be set before initialize" with the TabControl. Were you able to solve it?

It does not always happen though, and it happens only on our hosted site.


No, never did solve it. Ended up removing the sriptmanager from the master page and sticking it into every downsteam page that needed ajax. No very elegant but there you are.

Anyone knows how to solve this problem besides putting Script Manager on every page?

pretty anoyying problem.


Did anyone find the solution for this issue. I have the script manager placed right after the form tag and this issue only comes up on hosted evniornment, it's working fine on my local machine.


I also have the same problem, If i put the scriptmanager in debug mode i get the error Sys.InvalidOperationException The component 'tabcontainername' cannot be found. I have a script manager at the top of my page but this makes no difference. I have trawlled through the web but without anyluck, Anyone have a clue how to fix this.


I'm not sure but it could be the same problem that i'have been in some time ago. You can take a look at this post : http://forums.asp.net/t/1092293.aspx

The problem was occuring only in IE6 for me and it was because of a javascript bug caused when there is a lot of AjaxControlToolkit controls on the page. I haven't found a real solution. The only thing i thinked about was to remove the webparts menu that were causing the script tags opening and closing that were responsible for the bug in my case.

Hope this can help you ;)


Hi Guys,

I found a hack that works, The scriptmanager includes add_init functions to the bottom of the page this can be seen when you view source i discovered that if i ran these functions once the page was loaded it resolved the problem. Its not an ideal solution but it works for me. I spent a while trying to resolve this problem and this was the only way i could fix it. Hope it helps someone.

var tabs = $find('ctl00_BodyPlaceHolder_tcAttendees');

if(tabs ==null)

{

Sys.Application.add_init(function() {

$create(AjaxControlToolkit.TabContainer, {"activeTabIndex":0,"clientStateField":$get("ctl00_BodyPlaceHolder_tcAttendees_ClientState")},null,null, $get("ctl00_BodyPlaceHolder_tcAttendees"));

});

Sys.Application.add_init(function() {$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_0")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_0"));

});

Sys.Application.add_init(function() {

$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_1")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_1"));

});

Sys.Application.add_init(function() {$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_2")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_2"));

});

Sys.Application.add_init(function() {

$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_3")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_3"));

});

Sys.Application.add_init(function() {$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_4")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_4"));

});

Sys.Application.add_init(function() {

$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_5")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_5"));

});

Sys.Application.add_init(function() {$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_6")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_6"));

});

Sys.Application.add_init(function() {

$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_7")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_7"));

});

Sys.Application.add_init(function() {$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_8")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_8"));

});

Sys.Application.add_init(function() {

$create(AjaxControlToolkit.TabPanel, {"headerTab":$get("__tab_ctl00_BodyPlaceHolder_tcAttendees_9")},null, {"owner":"ctl00_BodyPlaceHolder_tcAttendees"}, $get("ctl00_BodyPlaceHolder_tcAttendees_9"));

});

tabs = $find('ctl00_BodyPlaceHolder_tcAttendees');

document.getElementById('ctl00_BodyPlaceHolder_tcAttendees').style.visibility ='visible';

tabs.set_activeTabIndex(0);

}

Haven't really investigated but if you look at the tab example in the toolkit and steal this code as the basis for the control it works.. Maybe it needs to tabcontainer wrapper or something?

<ajaxToolkit:TabContainerrunat="server"ID="TabContainer1">

<ajaxToolkit:TabPanelrunat="server"ID="TabPanel1"HeaderText="TabPanel1">

<ContentTemplate>

TabPanel1

</ContentTemplate>

</ajaxToolkit:TabPanel>

<ajaxToolkit:TabPanelrunat="server"ID="TabPanel2"HeaderText="TabPanel2"Enabled="false">

<ContentTemplate>

TabPanel2

</ContentTemplate>

</ajaxToolkit:TabPanel>

<ajaxToolkit:TabPanelrunat="server"ID="TabPanel3"HeaderText="TabPanel3">

<ContentTemplate>

TabPanel3

</ContentTemplate>

</ajaxToolkit:TabPanel>

<ajaxToolkit:TabPanelrunat="server"ID="TabPanel4"HeaderText="TabPanel4"DynamicServicePath="~/ToolkitTestService.asmx"DynamicServiceMethod="GetContextKey"DynamicContextKey="Web Service Success"/>

</ajaxToolkit:TabContainer>


No it doesn't. Exacltly the same problem.


Hi Kevinof,

if you are not using webparts remove the reference ( using System.Web.UI.WebControls.WebParts;

) to it in the cs page. This removed the error for me. Hope this works for you.

Thanks. MrD


Can anyone still provide the best possible solution to the "owner must be set before initialize" problem of the TabControl?

Is there a plan to fix this in future release?

No comments:

Post a Comment