我有一个项目,我正在尝试在页面上注册自定义服务器控件(没有.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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的页面上,
<%@ Register TagPrefix="myControls" Namespace="MyApp.Controls" %>
<myControls:CustomControl runat="server" Text="What up!" />
Run Code Online (Sandbox Code Playgroud)
我收到一个Parser Error,消息"Unknown server tag'myControls:CustomControl'."
我究竟做错了什么?
asp.net custom-server-controls servercontrols asp.net-customcontrol asp.net-controls
asp.net ×1