Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Sun, 30 Mar 2008 05:29:00 -0700,    group: microsoft.public.dotnet.framework.aspnet.buildingcontrols        back       


Error when Load control dynamically with LoadControl   
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.ascx"); 

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
date: Sun, 30 Mar 2008 05:29:00 -0700   author:   Stephane

RE: Error when Load control dynamically with LoadControl   
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.ascx"); 
> 
> 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
>
date: Sun, 30 Mar 2008 07:39:01 -0700   author:   Stephane

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us