Reputation: 6338
I am trying to extend System.Web.UI.WebControl.Panel
control. Below is my .cs code.
namespace XControls
{
public class VisibilityChangedEventArgs : EventArgs
{
public bool Visible { get; private set; }
public VisibilityChangedEventArgs(bool visibility)
{
Visible = visibility;
}
}
public class XPanel : Panel
{
public EventHandler VisibleChanged;
public override bool Visible
{
get
{
return base.Visible;
}
set
{
base.Visible = value;
OnVisibleChanged();
}
}
protected void OnVisibleChanged()
{
if (VisibleChanged != null)
VisibleChanged(this, new VisibilityChangedEventArgs(Visible));
}
}
}
And in default.aspx
file first I register my XPanel.
<%@ Register TagPrefix="xc" Namespace="XControls" %>
And down in code try to use like this.
<xc:XPanel runat="server" id="xp">
Hello XPanel
</xc:XPanel>
But When I try to run this in browser I get an error:
Server Error in '/' Application.
Parser Error
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 'xc:XPanel'.
So what is the problem? What I am doing wrong?
Upvotes: 0
Views: 57
Reputation: 1881
You need to add assembly name as well when you register your control.
<%@ Register TagPrefix="xc" Namespace="WebApplication1" Assembly="WebApplication1" %>
Upvotes: 3