Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)
        {
            base.RenderBeginTag(writer);
            if (base.DesignMode)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
            }
        }
    }
}

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.

Thanks

Holger

share

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?

share
    
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
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 '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

This site is currently not accepting new answers.