asp.net add custom control in website

Deadly 提交于 2019-12-06 01:37:54

Use the Register tag correctly:

<%@ Register TagPrefix="my" TagName="control" Src="~/Path/To/Your.ascx" %>

The syntax you specify is for when your controls are in another assembly.

You need to add a DLL project to your solution and reference it in your web project, or if you develop the DLL outside the web solution, simply add a reference to the compiled DLL. Next, you need to register the control in your web.config or at the page level. I do not recommend developing custom controls within a web site project.

<%@ Register TagPrefix="ControlVendor" Assembly="ControlVendor" %>

Check out this website. http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx

If you're set on creating custom controls within a website project, the class does have to reside in the App_Code folder, but the registration isn't straight forward because Microsoft prepends the namespace with ASP. I had a very difficult time doing it this way so I created a DLL project.

Have you checked that your custom component output binary is name AnkitControls.dll ? Did you added it as a reference in your website properties ?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!