When using the UltraWebTab, it was possible to gain access to a tab's UserControl in code behind after setting the UserControlURL value. However, in using the WebTab and ContentTabItems, this seems impossible.
Through reflection (and the debug panel) it seems the UserControl is the 0-indexed control of the ContentTabItem's TemplateContainer. However, TemplateContainer is not available at runtime due to its protection level.
Can someone PLEASE show me the magic needed to access a UserControl added to a ContentTabItem via the UserControlUrl property?
For reference, I am able to access it via:
Dim uc2 As New Objectuc2 = Me.tabs.FindControl("tmpl" + CStr(tabIdx)).Controls(0)If Not IsNothing(uc2) Then uc2.typeid = row.Item("expressionoperatortypeid")End If
But that seems REALLY fragile as I have to increment the tabIdx each time I add a new tab.
Hello kal_patel,
Thank you for posting in the Community.
The approach you are using for accessing the usercontrol object is sound, however I would suggest that you operate with indeces in this scenario:
WebTab1.Tabs(0).Controls(0).Controls(0)
If the userControlUrl is set, there is not need to access the template control by its id (and instead of tabIdx the count in the Tab() collection may be checked).
Please let me know if you have any questions.
Hi kal_patel,
Please do not hesitate to contact me if you have any further questions regarding this matter.
Petar,
Thanks. Is there _any_ way to reference the contained ASCX by "name" rather than index? It certainly would make the code easier to read.
Regards,
Thank you for your reply.
The user control would be named "ctl00" when assigned to the UsetControlUrl. Therefore you may try something similar to:
WebTab1.Tabs.FindTabFromKey("MyTab2").FindControl("ctl00")
Please let me know if this helps.
Can not find control within ContentTabItem when pro grammatically added.
I used previously some controls but its controls is totally exceptional for every programmer and unused controls. So I strongly believe that If We used this controls in web apps, it will burden for us.
Regards
Suday
Please contact me if you have any further questions regarding this matter.