How to reference custom control from App_Code folder?

A

Alan Silver

Hello,

I have a custom control that is inside a DLL. Until now, I have had the
source file for this DLL in a development folder on my machine, and I've
been compiling it using csc on the command line. I reference the control
in the DLL on a master page by adding the line to the top of the file...

<%@ Register TagPrefix="Fred" Namespace="FredECommerceControls"
Assembly="ECommControls" %>

....and then something like this where I want the control...

<Fred:SiteLinks PreSep="" runat="server" />

This all worked fine, but didn't let me debug the control in VWD as it
didn't have the source file.

I tried creating an App_Code folder and putting the source file in there
(deleting the DLL from the bin folder), but this gave the following
error when I tried to run the page...

Element 'SiteLinks' is not a known element. This can occur if there is a
compilation error in the Web site.

I presume that it's not compiling the source file, so it can't find the
assembly containing the control. The question is, why? I thought the
whole idea of putting the source file in App_Code was so that it would
automatically be compiled.

Anyone any ideas? TIA
 
T

Teemu Keiski

If you reference it from App_Code you need to omit the Assembly part of the
Regioster directive, since it's not in an named assembly.

<%@ Register TagPrefix="Fred" Namespace="FredECommerceControls" %>

E.g just have TagPrefix and the namespace declared.
 
A

Alan Silver

If you reference it from App_Code you need to omit the Assembly part of the
Regioster directive, since it's not in an named assembly.

<%@ Register TagPrefix="Fred" Namespace="FredECommerceControls" %>

E.g just have TagPrefix and the namespace declared.

Thanks, that's great.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top