gpt4 book ai didi

asp.net - 使用 Web 项目在程序集中注册自定义类

转载 作者:行者123 更新时间:2023-12-04 06:27:46 24 4
gpt4 key购买 nike

我正在使用网络项目和网络表单。

我创建自定义类

 Namespace CustomWebControls
Public Class NoValidationDDL
Inherits DropDownList


End Class
End Namespace

我尝试在程序集 web.config 页面部分注册这个类
<controls>
<add tagPrefix="customDDL" namespace="CustomWebControls" assembly="ae" />
</controls>

并尝试在 ascx 中使用
<customDDL:NoValidationDDL ID ="id" runat="server"></customDDL:NoValidationDDL>

我怎样才能在网络项目中做到这一点?

最佳答案

这应该可以工作(假设您的项目的程序集名称是 ae ) - 确保在创建/修改自定义控件后构建项目。除非您的 bin 目录中存在更新的“ae.dll”,否则智能感知等将无法工作。

除了修改 web.config,您还可以通过在 page 指令后添加 register 指令来尝试在 page(aspx) 或 control(ascx) 级别注册控制:

<%@ Register Assembly="ae" Namespace="CustomWebControls" TagPrefix="customDDL" %>

关于asp.net - 使用 Web 项目在程序集中注册自定义类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5830519/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com