SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to inherit the 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.



share|improve this question

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?

share|improve this answer
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 '11 at 16:17
If you dont add the full assembly (including version) name to either pages or Register, then doesnt know how to find your control. – djeeg Jan 21 '11 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 '11 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.