Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Unable to access UserControl added through ContentTabItem.UserControlURL in code behind
posted

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 Object
uc2 = 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.

Parents
  • 49378
    posted

    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.

     

     

Reply Children