ASP.NET Custom Controls

后端 未结 4 2054
你的背包
你的背包 2021-01-15 04:56

How do you create a custom control (not an ASCX control) and, more importantly, use it in your project? I\'d prefer not to create a separate project for it or compile it as

4条回答
  •  醉酒成梦
    2021-01-15 05:28

    You mentioned that you wanted to avoid creating a separate project. As the other responses have indicated, it is far more common to simply create a new project to store your custom controls and reference it. It is possible, however, to register a control defined in the same project, using the regular syntax:

    <%@ Register TagPrefix="Example" Namespace="CustomControls" Assembly="CustomControls" %>
    

    Where the "Assembly" is the assembly where both the control and the page is located. This works much easier if you are using a Web Application Project, rather than a Web Site.

提交回复
热议问题