loading controls at runtime

modularbeing

Regular
Joined
Jan 8, 2004
Messages
63
I have a function that loads a user control from an ascx using LoadControl() and passes back the loaded control to the calling procedure. the problem I am running into is that I need to set a property of the user control before I add it to the page and I was trying to do it in my function that creates it but I cannot figure it out....

this is the function I am using to load the control and pass it back

Code:
        Public Function AddGroupControl(ByVal ctrlName As String) As Control
            Try
                AddGroupControl = LoadControl("~/UI/Controls/" & ctrlName & ".ascx")
                AddGroupControl.ID = ctrlName
            Catch ex As Exception
                Throw ex
                Exit Function
            End Try
            Return AddGroupControl
        End Function
 
Back
Top