Can you add a System.Web.UI.UserControl to AJAX TabPanel?

M

Mike

Hi. I'm trying to add a System.Web.UI.UserControl (Not a
System.Web.UI.WebControl) to an asp.net ajax tabpanel.

Unfortunately it doesn't appear that this is possible. This question could
get very detailed, but I'll keep it short. I have a subroutine shown below
which adds a tabpanels to a tabcontainer(Tabs1) based for each object in a
collection. Then for each tabpanel I try to add a usercontrol named
uWebPage. But when the Page_Load event for uWebPage fires I get null
reference exceptions when referencing controls on uWebpage.

Is this situation I'm trying (adding usercontrol to tabpanel) even possible?
Thanks!


------------------------------------------------------------------------------
Dim oNewTab As AjaxControlToolkit.TabPanel
Dim uWebpage As uWebpage

For Each oAssociation As UserVideoAssociation In oAssociations
For Each oWebpage As Webpage In oAssociation.Webpages
oNewTab = New AjaxControlToolkit.TabPanel

uWebpage = New uWebpage
uWebpage.DomainName = oAssociation.DomainName
uWebpage.Webpage = oWebpage.Webpage

oNewTab.Controls.Add(uWebpage)

oNewTab.HeaderText = oWebpage.Webpage
Tabs1.Tabs.Add(oNewTab)
Next
Next
------------------------------------------------------------------------------
 
M

Milosz Skalecki [MCAD]

Howdy,
Howdy,

Dynamic user controls require a call to LoadControl method instead of
constructor:

For Each oAssociation As UserVideoAssociation In oAssociations
For Each oWebpage As Webpage In oAssociation.Webpages

oNewTab = New AjaxControlToolkit.TabPanel

uWebpage = CType(LoadControl("locationoftheusercontrol"), uWebpage)
uWebpage.DomainName = oAssociation.DomainName
uWebpage.Webpage = oWebpage.Webpage

oNewTab.Controls.Add(uWebpage)

oNewTab.HeaderText = oWebpage.Webpage
Tabs1.Tabs.Add(oNewTab)
Next
Next

Hope this helps
 
M

Mike

Awesome! Thank you so much!

Milosz Skalecki said:
Howdy,
Howdy,

Dynamic user controls require a call to LoadControl method instead of
constructor:

For Each oAssociation As UserVideoAssociation In oAssociations
For Each oWebpage As Webpage In oAssociation.Webpages

oNewTab = New AjaxControlToolkit.TabPanel

uWebpage = CType(LoadControl("locationoftheusercontrol"), uWebpage)
uWebpage.DomainName = oAssociation.DomainName
uWebpage.Webpage = oWebpage.Webpage

oNewTab.Controls.Add(uWebpage)

oNewTab.HeaderText = oWebpage.Webpage
Tabs1.Tabs.Add(oNewTab)
Next
Next

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top