ASP.NET Web 用户控件库 [英] ASP.NET Web User Control Library

查看:17
本文介绍了ASP.NET Web 用户控件库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一堆用户控件,我们想将其从 Web 应用程序中提取到单独的程序集/库中,我认为这就像创建一个类库并提取 ascx 和 ascx.cs 文件一样简单进入项目,并编译一个 DLL 以在我们的应用程序中重用.

We have a bunch of user controls we would like to pull out of a web application and into a separate assembly/library, and I thought it would be as simple as creating a class library and pulling the ascx and ascx.cs files into the project, and compiling a DLL to be reused among our applications.

但事实并非如此.

我们的最终目标是拥有一个可分发到任何 Web 应用程序中的可分发 DLL(类似于 Telerik 分发其控件的方式).此处的步骤:将 .ascx 用户控件转换为可再发行自定义控件遵循起来非常简单,但是这会导致许多名为 controlname.ascx.guid.dll 的文件,这不是预期的结果.无论如何,我什至无法让这些工作,因为我们还有其他类需要编译到程序集中.

Our ultimate goal is to have a single distributable DLL (similar to how Telerik distributes their controls) that we can throw into any web application. The steps here: Turning an .ascx User Control into a Redistributable Custom Control were very simple to follow, however this results in many files named controlname.ascx.guid.dll, which is not the desired result. I couldn't even get these to work anyways, since we have additional classes that need to be compiled into the assembly.

是否有人在 .NET 中成功创建了 Web 用户控件库(我们这里使用的是 3.5)?我似乎找不到很好的分步指南.

Has anyone successfully created a web user control library in .NET (we're using 3.5 here)? I can't seem to find a nice step-by-step guide.

推荐答案

如果你想在项目之间共享控件,我的经验表明最好的方法是构建自定义的asp.net服务器控件而不是用户控件.用户控件适合在同一个项目中共享,但不能在多个项目中共享.

If you want to share controls among project, my experience has shown that the best way is to build custom asp.net server controls instead of usercontrols. User controls are good for sharing within the same project, but not over multiple ones.

为此,我建议您在类库中构建一组自定义服务器控件,并将其用于您的所有项目.

For this purpose I suggest you to build a set of custom server controls inside a class library and use that on all of your projects.

这本书很好地解释了创建服务器控件的基础知识

This book does quite a good job at explaining the basics of creating server controls


我目前正在开发一个 .net Web 服务器控件库.我实际上没有遵循任何分步指南.我主要考虑使用我上面提到的书和 MSDN 库 + Reflector,这是检查现有 MS 服务器控件并从中学习的好工具.


I'm currently developing a .net web server control library. I actually didn't follow any step-by-step guide. I mostly considered using the book I mentioned above and the MSDN library + Reflector, which is a great tool for inspecting existing MS server controls and learning from them.

这篇关于ASP.NET Web 用户控件库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆