I need to inherit the asp.net Treeview for fixing a rendering issue. I am currently trying to accomplish that in an Sharepoint project that also contains various other things like webparts, aspx, images, etc.

I tried to do it like this the first time:

namespace MyNamespace.Controls
    [ToolboxData("<{0}:TreeViewAdv runat=server>")]
    public class TreeViewAdv : TreeView
        public override void RenderBeginTag(HtmlTextWriter writer)
            if (base.DesignMode)

When I now try to use that control in an aspx inside that assembly, I am not able to reference the control with a statement like this:

"<%@ Register TagPrefix="custom" Namespace="MyNamespace.Controls" %>"

The question is: Is this supposed to work? Do I really have to create a second assembly for that only hosting server controls (hope not)?

Every hint is highly appreciated.



2 Answers 2


The Register tag most likely needs to have an assembly attribute.

Unless you add the assembly hint to the <pages> element in web.config

You may also need a <SafeControl> element

Is your library getting installed into the GAC?

  • Yes, it is added to GAC. There is a safecontrol element added with type *, that all types of the namespace are safe. Didn't add it to pages in web.config (as this assembly has only a app.config that is somehow not added to the web.config, may be this is an issue?). I also tried it with the assembly attribute, without version but no luck. It didn't work either.
    – user2174
    Jan 21, 2011 at 16:17
  • 1
    If you dont add the full assembly (including version) name to either pages or Register, then asp.net doesnt know how to find your control.
    – djeeg
    Jan 21, 2011 at 22:46
  • It doesn't help. I'll go write some testers for that. Meanwhile I could solve my issue without inheriting the treeview, so there is no pressure behind it. Thanks anyway for your help.
    – user2174
    Jan 22, 2011 at 15:43

I beleive you need to your class assemblies via the package designer, like below enter image description here

After that you can reference your assemblies in your solution like below

enter image description here

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy