asp.net - 自定义控件同一程序集 - 可视 Web 部件

标签 asp.net sharepoint

我正在开发一个需要创建自定义控件的可视化 Web 部件。我正在尝试将自定义控件添加到与 Visual Web 部件相同的程序集,并将控件注册为:

<%@ Register TagPrefix="cus" Namespace="SomeCustomControlNameSpace" %>

当我尝试访问它时,它会抛出运行时错误:

未知的服务器标记“cus:ControlName”。

我需要为此创建任何 Web.Config 条目吗?

有什么想法吗?

最佳答案

也许您已经尝试过这个(并且厌倦了听到它),但我已经通过使用程序集标记来引用自身来实现此场景。我的项目是一个 Web 应用程序,因此这可能不适用于网站项目。不管怎样,这是我的网络应用程序属性:

Web Application Properties. Assembly name is: Example.Web

在我的页面上,在同一个程序集中,我有以下 Register 指令:

<%@ Register TagPrefix="jb" Namespace="CustomControlNameSpace" assembly="Example.Web" %>

作为旁注,以下是 Microsoft says about it (其中没有提到我上面尝试过的内容):

When you use the @ Register directive to reference a control, you can place the code for the control in the following places:

  • As source code in the application's App_Code folder, where it will be dynamically compiled at run time. This is a convenient option during development. If you choose this option, you do not use the assembly attribute in the @ Register directive.

  • As a compiled assembly in the application's Bin folder. This is a common option for deployed Web applications.

  • As a compiled and signed assembly in the global assembly cache (GAC). This is a common option if you want to share a compiled control among multiple applications. You can reference a control in the GAC by assigning an identifying string to the assembly attribute. The string specifies the required details about the control, including its fully qualified type name, its version, its public key token, and its culture.

关于asp.net - 自定义控件同一程序集 - 可视 Web 部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3014237/

相关文章:

c# - 为什么 selectedindexchanged 不触发?

c# - 在 gridview 和数据上添加一个额外的列

c# - JQuery 中的自动完成

email - SharePoint 向字段中指定的用户发送电子邮件

javascript - 使用 jQuery/javascript 如何检查 JS 文件 ( SP.JS) 是否已在页面中调用?

javascript - 如何在 ajax 调用中访问 Sharepoint REST api

托管在 IIS7 上的 ASP.NET 应用程序忽略自定义错误并回退到 IIS 错误

c# - 使用 Webservice 填充 Jquery 数据表

c# - 从 Sharepoint 流式传输 WCF

Excel VBA : Catching an external data connection that won't refresh?