0

Hello all,

I'm having a little melt-down trying to work out how to call a method of a dynamically loaded control...

My setup is this:

Admin.aspx
CustomControl.ascx

Admin.aspx has the following code to load CustomControl.ascx:

UserControl UC = (UserControl)LoadControl("~/admin_custom_controls/howComments.ascx");

        modulesPlaceHolder.Controls.Clear();
        modulesPlaceHolder.Controls.Add(UC);

CustomControl.ascx has a method:

public void initiate()
    { 
      getComments("All");
            getUsers();
    }

What I'm trying to do, is call the initiate() method from the Admin.aspx
Tried everything, and trawled the web for hours!!!
Help! :)

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by dimmslider
0

I'm a tad confused... What type can a WebUserControl be cast to if not UserControl?
:confused:
I'm calling the control to be displayed and the control has some internal logic, which is controlled using the interface on that control. It's just that I need to call one of it's public methods from the parent page as I'm about to display it...

Cast it into the type that it is, not UserControl. You should be able to access it then.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.