3

I am banging my head against the brick wall today. I am porting a site I had developed on an old box across to a new dev env. I have not just copied all the files as I didn't have a great file structure and some parts of the code needed to be removed as I went along.

Originally I had created a website (File -> New -> Web Site). I wanted a file structure something like:

Popular folder structure for build

So I created a new blank solution so the sln file was on its own, then added projects (various DLL projects) and am ASP.NET Web Application.

This last part seems to have caused me a few issues that have given me a headache. As far as I understand (this could be a little limited), a website (as I first had) is different to the later type I created. For example the App_Code folder part didn't work as before. To solve that I created a separate DLL for the webLibrary cs files and added a reference to it.

My problem now is how I register this on a page to be able to use the controls in it. For example I have a control that inherits from TextBox, when it was in the App_Code folder I could use:

<%@ Register TagPrefix="sarg" Namespace="MyNameSpace" %> 

Then use

<sarg:SARGTextBox id="clienttitletxtbox" runat="server" OnTextChanged="textboxfiltering_TextChanged" AutoPostBack="true"></sarg:SARGTextBox>

Now it is in its own DLL and namespace I can not figure out how to get it to work, I just keep getting warnings saying "Cannot resolve symbol 'SARGTextBox'".

It is probably really simple but I can no longer see the wood for the trees.

Thanks

Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
Jon
  • 15,110
  • 28
  • 92
  • 132
  • Thank you both, you are both right, I like the web.config solution more as I only have to do it once. Main problem turned out to be ME! shock horror, a user error! Thanks – Jon Oct 17 '09 at 22:01

2 Answers2

3

I think you have created a WebApplication instead of Website. WebApplication does not support App_Code.

  1. Add your ClassLibrary as a reference.
  2. Then In web.config register your control.
    <pages>
        <controls>
            <add tagPrefix="myctl" namespace="Namespace.ClassName" assembly="AssemblyName"/>
        </controls>
    </pages>
  1. Rebuild your solution.
  2. Open the page and find your control from Toolbox and drop it on your page,
Lee Taylor
  • 7,761
  • 16
  • 33
  • 49
m3kh
  • 7,881
  • 2
  • 31
  • 37
3

You need to specify the assembly where your control is declared :

<%@ Register TagPrefix="sarg" Namespace="MyNameSpace" Assembly="MyLibrary" %>
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758