Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / March 2008

Tip: Looking for answers? Try searching our database.

Error when Load control dynamically with LoadControl

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephane - 30 Mar 2008 13:29 GMT
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
Stephane - 30 Mar 2008 15:39 GMT
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

> Hi,
>
[quoted text clipped - 33 lines]
>
> Stephane

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.