"Unknown server tag" problem when creating custom control

Mar 3, 2009
Reaction score
I have been stuck for several days already. I desperately need some help.

I am using Asp.Net 2 and VS2005. I am using a TreeView control and am trying to get a click event from a SAME-NODE click event which isn't supported by TreeView. So I create a custom control (inherited control) from TreeView. But I can seem to get it work. There is no compilation error, but there is 'Unknown element' error in the aspx page. I still can run it, I got the following error when running.

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Unknown server tag 'mycontrol:WebCustomControl1'.

I register it as:

<%@ Register Namespace="CustomControls" TagPrefix="mycontrol"%>

and use it in my aspx page like this:

<mycontrol:WebCustomControl1 id="m_LeftTree" runat="server"


DataSourceID="m_XmlDataSourceTreeView" NodeIndent="10" SkipLinkText="" CssClass="minorSpace1" >


The custom control code is extremely simple. I just added from the IDE and change the base class to TreeView, so I haven't added any functionality. Here it is:


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Text;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace CustomControls

[ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]

public class WebCustomControl1 : System.Web.UI.WebControls.TreeView




public string Text



String s = (String)ViewState["Text"];return ((s == null) ? String.Empty : s);



ViewState["Text"] = value;


protected override void RenderContents(HtmlTextWriter output)






Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question