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

  • Thread starter Thread starter Mike
  • Start date Start date
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
------------------------------------------------------------------------------
 
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
 
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
 
Back
Top