ASP.NET 2.0 cannot load user control dynamically???

P

patrick.tsang

Hi guys,

I try to load a user control by using Page.LoadControl.

// in aspx page
Control l_oControl = Page.LoadControl("~/Controls/ucA.ascx");
ucA myUserControl = (ucA)l_oControl;

myUserControl.Name = "Hello world";

// in ascx ucA
public string Name
{
set {m_sName = value;}
}

I used this in .NET 1.1 and it works fine. But when i wrote the code in
the .NET 2.0 then i am not able to get ucA class properties, pretty
much give me exception for the casting from l_oControl to ucA. Any
idea?


Cheers,
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top