Why doesn't control load?

B

brett

I have a user control with a namespace similar to:

mysite.SomeApp.TheControl

In an aspx page, I'd like to load the above control based on its
filename. The page is in the same namespace, mysite.SomeApp and both
can see each other through intellisense. Session["NavControl"]
contains the text "TheControl.ascx". When I try to execute this code
in the aspx page

Control someControl = LoadControl(Session["NavControl"].ToString());

I get this exception

(8): error CS0117: 'ASP.SomeApp_TheControl_ascx' does not contain a
definition for 'mysite'

Any ideas what this means?

I have an imagebutton on the aspx page. When it is clicked, it simply
rotates two controls. So, on the first click, display controlA; on
the second click, display controlB; third click, controlA and so on.
Is there a better way?

Thanks,
Brett
 
G

Guest

Brett,

I suspect there's something wrong with your control's code. to make sure,
create a new page and drag and drop the control and run the page to see if
it's working OK. Maybe control loads OK, there's a bug in control page_init
or page_load event.
 

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

Top