Error when Load control dynamically with LoadControl

S

Stephane

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
 
S

Stephane

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
 

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,991
Messages
2,570,214
Members
46,801
Latest member
MandyYtw96

Latest Threads

Top