How to make usercontrol available to multiple projects?

自古美人都是妖i 提交于 2019-12-30 05:21:04

问题


I have a set of UserControls in a ASP.NET website that I would like to share to multiple website. But it seems we are unable to create a class library with UserControls in it with the ascx file. While MSDN suggest building a Web Control, I Would rather find a way to share the existent controls instead of destroying them to create new web controls.

Is there any way of creating a library of UserControls?

Thanks


回答1:


Here is one way of doing it:

Creating and Using User Control Libraries.




回答2:


You can't compile them into a project per se. You can get something close to this by linking the files into the project so there is one master version of the file but each project also has its own copy. You can either:

  • Using a source control share function to have one location and share it into the other projects
  • Create one project for the controls and then link them into other project by using "Add Existing Item", clicking the little arrow next to the Add button, and selecting "Add As Link".



回答3:


You should use instead a Composite control. Here is a comparison between web user controls and composite controls:

http://msdn.microsoft.com/en-us/library/aa719735(VS.71).aspx



来源:https://stackoverflow.com/questions/640516/how-to-make-usercontrol-available-to-multiple-projects

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