How do I add a link to a control on my current website in web.config

I extended the server control (not the custom control) and put the code in the app_code folder. I would like to add a tag prefix to the web config, but

<add tagPrefix="cc1" namespace="mynamespace" />

      

and

<add tagPrefix="cc1" namespace="mynamespace" assembly="currentwebsitename" />

      

does not work. I am getting this error: Error 147 Unknown server tag 'cc1: Control'

+2


source to share


2 answers


To register the server controls found in the App_Code folder, you only need the tag prefix and namespace. So in web.config it will look like this ...

<add tagPrefix="cc1" namespace="mynamespace"/>

      

And on the page it will look like this ...



<%@ Register TagPrefix="cc1" Namespace="mynamespace" %>

      

One of the reasons to look out for is that, by default, website projects do not contain a namespace at all when you add a new item to the App_Code folder, so you need to explicitly ensure that your controls have a namespace.

+4


source


You will need to put the control in a DLL named "currentwebsitename.dll" (if you want it to work in the second way), or you need to specify the source via an attribute src

(if you want to do it the first way):

<add tagPrefix="cc1" namespace="mynamespace" src="app_code/control_name_here"/>

      

Try reading these two articles:



http://msdn.microsoft.com/en-us/library/sbz9etab.aspx and

http://msdn.microsoft.com/en-us/library/yhzc935f.aspx

+1


source







All Articles