LoadControl returns a a Control type...which your specific control inherits
from. You need to cast what is returned (Control) back up to the specific
type you want:
Login login = (Login)LoadControl("controls/Login.ascx")
panel1.Controls.Add(login)
login.MyFunction();
this is assuming the type of your control is "Login"
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Christian Ista" <ml@cista.be> wrote in message
news:eE****************@TK2MSFTNGP12.phx.gbl...
Hello,
I have a UserControl, added to a panel like this (in the Page_Load of
default.aspx).
Code :
Control login = LoadControl("controls/Login.ascx");
panel1.Controls.Add(login);
No problem.
In the codebehind of this UserControl, I have a public method.
but in the Page_Load I can't access it, the method is unknown
I tried this : login.MyFunction(); The method doesn't appear in the method
list and we are in the same namespace.
Do you know why ?
Thanks,
Christian,