Showing posts with label source. Show all posts
Showing posts with label source. Show all posts

Monday, March 26, 2012

How do I dynamically create TabPanels in codebehind?

I have tried creating TabPanels dynamically in Page_Init but they aren't showing up even though I do see them when doing View Source on the resulting page. When I add them statically with the designer, they do show up. I am using 10618 version of the toolkit.

Here is a code snippet:

protected void Page_Init(object sender, EventArgs e){ AjaxControlToolkit.TabPanel tp =new AjaxControlToolkit.TabPanel(); tp.ID ="DynamicTab1"; tp.HeaderText ="DynamicTab1" Label tabContents =new Label(); tabContents.Text = tp.HeaderText; tp.Controls.Add(tabContents); ExistingTabContainer.Tabs.Add(tp);}

Hi,

I'd do this dynamic tab panel creation this way (it also works in the Page_Load event handler):

protected override void OnInit(EventArgs e){base.OnInit(e);// Create the tab panel's content container Control tabContent =new Control(); TabPanel tab =new TabPanel(); tab.ID ="tabPanel1"; tab.HeaderText ="Dynamic Panel"; Label label =new Label(); label.Text ="This is a dynamic tab panel"; tabContent.Controls.Add(label); tab.Controls.Add(tabContent);this.tabContainer1.Tabs.Add(tab);}

This pice of code works for me perfect. The tabContainer1 control is of type AjaxControlToolkit.TabContainer and is declared on the page this way:

<ajaxcc:TabContainer ID="tabContainer1" runat="server"></ajaxcc:TabContainer>

Kind regards,

sbogus.



sbogus, I got it to work using your sample code. I really appreciate your help.

Cheers!

Ron

How do i change the source code for an extender?

Hi all,

I have searched the forums, documentation and google but haven't found any help yet (mayby i'm searching for the wrong things). I need to modify ModalPopupExtender and have found the code i need to modify in the ModalPopupBehaviour.js but how can i change that code so that everytime i use a modalopupextender in my project it uses my modified extender. I'm guessing that i have to build it/something again but is it the cs project that i got when i downloaded the toolkit?

Could someone point me in the right direction mayby there is some kind og guide or how to that i haven't found. Or explain what i need to do.

Lot's of thanks!

Thought i'd explain what i wan't to achive.

In the modalpopupbeahvoiur code this code creates the background div: 
this._backgroundElement = document.createElement('div');this._backgroundElement.style.display ='none';this._backgroundElement.style.position ='fixed';this._backgroundElement.style.left ='0px';this._backgroundElement.style.top ='0px';// Want zIndex to big enough that the background sits above everything else // CSS 2.1 defines no bounds for the <integer> type, so pick arbitrarilythis._backgroundElement.style.zIndex = 10000;if (this._BackgroundCssClass) {this._backgroundElement.className =this._BackgroundCssClass; }

I want to attach an onclick animation so that if a user clicks the background div then the modalpopup itsel should pulse. I thought of changing the above javascript code so that the div also got an id to witch i could attach the animation extender. But i don't know how to make my changes to the javascript code reflect in my project (see original post).

Is there perhaps an other way to create this animation? It should be somethink like if you bring up IE's properties window and click somewhere outside of it then the header flasehs.

Thanks again


I've shown how to modify the Javascript in an existing extender (in this case the ListSearch extender, to speed it up with massive lists) here:

http://damianblog.com/2007/06/19/speeding-up-listsearchextender/

You should be able to do the same kind of think with your changes to the ModalPopup. The key is to ensure that your web project references the newly build toolkit DLL.

Damian


Thanks! I'll check that out and get back when I get it to work! :)


I got it to work and thanks for your reply!

If anyone else wonders or reads this what i needed to do was to open the project file that was in the toolkit catalog and make my changes in the .js file then rebuild the project and make sure that my project (where I needed to use the changed extenders/behaviors) referenced to that newly build toolkit DLL in the toolkit bin debug or release folder.

/peronn