Monday, March 26, 2012

Tab Control Disappears when passing parameter to JavaScript function

Hello everybody!

I have a quite strange error on my hands here. And just to explain, this is what I want to do:

I created a tab control (AJAX) by:

"privatevoid constructTabs()

{

AjaxControlToolkit.TabContainer myTabs=new AjaxControlToolkit.TabContainer();

myTabs.Tabs.Add(loadPanel("NameOfTabGoesHere")); //this is donen times

myTabs.ActiveTab = productTabs.Tabs[0]; //to set the first tab as the active tab

myTabs.OnClientActiveTabChanged = "inVisiblePlans('" +myTabs.ActiveTab.ID.ToString() + "')"; //inVisiblePlans is my javascript function

Panel newPanel =newPanel();

newPanel.Controls.Add(productTabs);

this.Controls.Add(newPanel);

}

"

the function works ok but the problem is, the tab controls cannot be seen? it(the panel) is actually rendered with "hidden" attribute. And the strange thing is, if I domyTabs.OnClientActiveTabChanged = "inVisiblePlans";

The panels are visible but the page is of course useless.

All help will be greatly appreciated! Thanks is advance

Eduardo

Hello again.. about 15 minutes after I posted my question.. I got the answer myself... *slaps himself on the foreheadStick out tongue

instead of usingOnClientActiveTabChanged , I used this:

tabPanel.OnClientClick ="function(){inVisiblePlans('" + tabPanel.ID.ToString() +"');}";

everytime I add a tabPanel.

meaning:

I did not attach the javascript to the whole tabcontrol but attached a call to it in every panel and it works fine now. Am still wondering tho, why the first idea did not work.

Am posting this for all who experience the same problem.

Many thanks!

No comments:

Post a Comment