我有一个项目,我正在尝试在页面上注册自定义服务器控件(没有.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
我遇到了一个奇怪的错误(不是很奇怪,我想这是因为我可能不知道某些最大长度限制)。我正在开发一个自定义服务器控件,它为员工呈现自定义搜索服务。成功搜索到员工后,我从 WCF 服务中以 json 形式获取他们的整个对象(列表),将字符串保存在隐藏字段中,并回发后面的代码以获取 json 字符串并反序列化为对象。现在,多达 2000 个对象,它完美地工作,但是当搜索条件开始获取 2000 以上时,开始出现以下错误
Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0
Run Code Online (Sandbox Code Playgroud)
我也调试了代码,但是 c# 代码甚至没有捕捉到任何调用。我还尝试将对象的 json 字符串保存在多个隐藏字段中,每个字段在 json 字符串中有 1000 条记录。但是,错误仍然不断出现。这告诉我表单的最大尺寸有某种限制。我能得到这个问题的任何解决方案,还是我必须将 Id 发送到后面的代码并从那里的服务中获取对象?实际上,服务 url 应该是动态的,宿主应用程序会提供它,所以我试图不引入任何 C# 级别的服务绑定(我猜你明白了)。
我有一个自定义的asp.net服务器控件来显示图像.我现在需要的是在图像的中心绘制一个矩形,并通过拖动它的边缘来重新调整矩形.是否可以使用JavaScript实现这一点?我需要将该脚本嵌入该控件中.可能吗 ?