Registering a Control Defined inside of a web solution
Posted
Thursday, April 03, 2008 2:36 PM
by
Nathan Zaugg
I've come across this several times. You build a custom control inside of your web_code folder and you can't reference it from your project because you can't figure out what assembly your supposed to reference (as your web code doesn't normally have a set assembly name). I finally figured out how to do this recently.
Normally you're tempted to put something like this:
<%
@ Register Assembly="MyWebComponent" TagPrefix="as" %> When really you need to put something like this:
<%
@ Register Namespace="NSM.WebControls" TagPrefix="as" %> The only trick is that you need to make sure you put your custom class inside of a set Namespace. Normally any class inside of a web project doesn't belong to a specific namespace.
Now we can reference our control:
<as:MyWebComponent ID="MyControl1" runat="server" />