我有一个项目,我正在尝试在页面上注册一个自定义服务器控件(没有.ascx
文件)。我目前正在使用
类声明
namespace MyApp.Controls{
public class CustomControl: WebControl{
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);
}
}
}
在我的页面上,
<%@ Register TagPrefix="myControls" Namespace="MyApp.Controls" %>
<myControls:CustomControl runat="server" Text="What up!" />
我收到解析器错误,消息为“未知的服务器标记 'myControls:CustomControl'”。
我究竟做错了什么?