"Unknown server tag" problem when creating custom control


Joined
Mar 3, 2009
Messages
2
Reaction score
0
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"

OnSelectedNodeChanged="OnLeftMenuClicked"

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

......
</mycontrol:WebCustomControl1>

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
{

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

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

{

[Bindable(true)]
[Category("Appearance")]

[DefaultValue("")]
[Localizable(true)]

public string Text
{

get

{

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

set

{

ViewState["Text"] = value;
}

}

protected override void RenderContents(HtmlTextWriter output)
{

output.Write(Text);

}

}

}
 
Ad

Advertisements


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

Top