You can create an interface that will be implemented by all custom controls. Thus, you can use this interface and use it to transfer your data through it. Consider this example:
public interface ICustomControl
{
string SomeProperty { get; set; }
}
... and your controls:
public class Control1 : Control, ICustomControl
{
public string SomeProperty
{
get { return someControl.Text; }
set { someControl.Text = value; }
}
}
Now you can do something like this:
Control userControl = Page.LoadControl(control);
Page.Controls.Add(userControl);
if (userControl is ICustomControl)
{
ICustomControl customControl = userControl as ICustomControl;
customControl.SomeProperty = "Hello, world!";
}
source
share