Problem adding/casting web user controls

J

Jason

I am trying to dynamically add a web user control - ctrlBlogEntry.ascx
- to a page - default.aspx - (via an ASP:placeHolder).

I was able to get it to work with the following:
controls_ctrlBlogEntry ctrlBE =
(controls_ctrlBlogEntry)LoadControl("/blog/controls/ctrlBlogEntry.ascx");

However, I starting experiencing problems with every other compile - it
started failing with the following error:
System.InvalidCastException: Unable to cast object of type
'ASP.controls_ctrlblogentry_ascx' to type 'controls_ctrlBlogEntry'.

I have also tried the following variations, but to no avail:
controls_ctrlBlogEntry ctrlBE =
(ASP.controls_ctrlblogentry_ascx)LoadControl("/blog/controls/ctrlBlogEntry.ascx");
ASP.controls_ctrlblogentry_ascx ctrlBE =
(ASP.controls_ctrlblogentry_ascx)LoadControl("/blog/controls/ctrlBlogEntry.ascx");

It has now started failing every time, but I can't figure out what's
going on.

Can someone see what I'm doing wrong?

Thanks!
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top