Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Error when Load control dynamically with LoadControl

Reply
Thread Tools

Error when Load control dynamically with LoadControl

 
 
Stephane
Guest
Posts: n/a
 
      03-30-2008
Hi,

I have created a user control (ASP.NET 2.0) in the folder "mining" of my
project. There's no namespace by default, but other aspx pages are in the
namespace iMinr.mining.

The declaration of this user control goes like this :

public partial class mining_ucPubDetails : System.Web.UI.UserControl

And in the ASCX page, this is the control declaration

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="ucPubDetails.ascx.cs" Inherits="mining_ucPubDetails" %>

Now, in a C# page in the iMinr.mining namespace where it's specified :

using iMinr.mining;

I try to load dynamically the control:

mining_ucPubDetails pub =
(mining_ucPubDetails)LoadControl("ucPubDetails.asc x");

And if I compile, I got this :

The type or namespace name could not be found

The weird thing is that it works on my dev server despite this error. But on
production, I doesn't.

Why the project can't find the control class? How can I load a user control
dynamically?

Thanks

Stephane

 
Reply With Quote
 
 
 
 
Stephane
Guest
Posts: n/a
 
      03-30-2008
Solved.

I added this to the aspx page where I use the control:

<%@ Register Src="ucPubDetails.ascx" TagName="ucPubDetails" TagPrefix="uc" %>
<%@ Reference VirtualPath="~/mining/ucPubDetails.ascx" %>

Steph

"Stephane" wrote:

> Hi,
>
> I have created a user control (ASP.NET 2.0) in the folder "mining" of my
> project. There's no namespace by default, but other aspx pages are in the
> namespace iMinr.mining.
>
> The declaration of this user control goes like this :
>
> public partial class mining_ucPubDetails : System.Web.UI.UserControl
>
> And in the ASCX page, this is the control declaration
>
> <%@ Control Language="C#" AutoEventWireup="true"
> CodeFile="ucPubDetails.ascx.cs" Inherits="mining_ucPubDetails" %>
>
> Now, in a C# page in the iMinr.mining namespace where it's specified :
>
> using iMinr.mining;
>
> I try to load dynamically the control:
>
> mining_ucPubDetails pub =
> (mining_ucPubDetails)LoadControl("ucPubDetails.asc x");
>
> And if I compile, I got this :
>
> The type or namespace name could not be found
>
> The weird thing is that it works on my dev server despite this error. But on
> production, I doesn't.
>
> Why the project can't find the control class? How can I load a user control
> dynamically?
>
> Thanks
>
> Stephane
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-05-2005 12:04 AM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-04-2005 07:57 PM
LoadControl() method throws virtual path error when attempting to load user control from subfolder. Jeremy ASP .Net 2 06-24-2004 05:57 AM
When does LoadControl really load the control? Rory Plaire ASP .Net Building Controls 2 08-12-2003 05:40 PM
Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack huobazi ASP .Net 1 07-03-2003 03:14 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57