Why doesn't control load?

  • Thread starter Thread starter brett
  • Start date Start date
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
 
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.
 
Back
Top