The Page.LoadControl method will actually return a reference to the control
MyControl myControl1 = (MyControl)Page.LoadControl("mycontrol.ascs");
You now have a reference to the control. You can now set any properties that
you have on the control such as
myControl1.MyParameter = "Something";
To access this value though, you need to be careful where you work with it.
If have code in the control's Page_Load event, override the OnPreRender
event and move the code there instead. The Page_Load event of the control
happens before the Page_Load event of the parent page so you have to use a
later event for the control.
Hope this helps,
Microsoft MVP - FrontPage
"Jill Graham" <jills_graham.au> wrote in message
> I can use following syntax to add user controls directly to my pages :
> <XYZ:myControl parameter1="value1" parameter2="value2" runat="server" />
> The control "myControl" is executed using the supplied parametersto> and parameter2
> Now my question :
> I've found two ways to add controls dynamically to my page :
> method 1
> page.loadControl("<.ascx file>")
> method 2
> activator.createInstance(type.getType("<class name>", true))
> The problem is : how can I pass the parameters parameter1 and parameter2> the control ?
> Thanks for any advice