我有一个ASP.NET网站,而不是Web应用程序,我已经建立了一个自定义CompareValidator
这是能够获得它自己的命名容器的外面的:如何让自定义控件可用于ASP.NET网站?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;
public class GlobalCompareValidator : CompareValidator
{
new protected void CheckControlValidationProperty(string name, string propertyName)
{
Control control = this.Page.NamingContainer.FindControl(name);
if (control == null)
{
throw new HttpException("Validator_control_not_found");
}
if (BaseValidator.GetValidationProperty(control) == null)
{
throw new HttpException("Validator_bad_control_type");
}
}
}
和存在于App_Code
目录代码。现在,我想用这个新的自定义控制的ASCX页面上是这样的:
<me:GlobalCompareValidator ID="compareValidator" CssClass="errorMessage" Display="None"
EnableClientScript="false" Text=" " ValidationGroup="LHError" runat="server" />
然而,试图注册的组件时使用它:
<%@ Register TagPrefix="me" Namespace="MyNamespace" Assembly="MyAssembly" %>
我得到这个错误:
Could not load file or assembly '...' or one of its dependencies. The system cannot find the file specified.
现在,这并不是真的那么令人惊讶,因为ASP.NET网站并没有真正生成这样的程序集。但是,如果我将Assembly
标签关闭,则无法找到GlobalCompareValidator
。当然,它也可能找不到Assembly
标签,但是这个错误很可能隐藏在找不到组件的事实中。
如何在世界中获得可用于ASP.NET网站的自定义控件?