构建服务器控件,例如 ComponentOne 或 ComponentArt 库

发布于 2024-10-07 12:51:04 字数 1159 浏览 0 评论 0原文

我是一位专业的 Web 开发人员,了解所有著名的 Web 框架。

我想构建一个服务器控件集合,例如 ComponentArt您可以在项目中使用的组件。

在ComponentArt中:您可以轻松地在项目中注册ComponentArt的命名空间,并将数据绑定到这些控件,而无需任何额外的代码或工作(例如将任何其他文件复制到我们的示例项目中),当然它们支持ajax。

为了实现这一目标,我开始意识到我必须开发一些高级 UserControls,支持处理 ajax 的回调,并且没有太多关于在不同项目之间共享 UserControls 的信息。实际上,这是唯一有用的链接: http://www.codeproject.com/KB /user-controls/EmbeddedUserControl.aspx

另一方面,服务器控件没有 ascx 模板接口,我可以轻松地设计我的控件布局。

我需要一种方法来开发一些 Web 组件,您可以:

  1. 轻松在其他项目之间共享(只需将 dll 添加到项目并启动 使用它)
  2. 支持ajax回调(例如ICallbackEventHandler)
  3. 可以有一个用于 HTML 设计的模板(例如具有 ascx 模板的 UserControl 文件),这样您就不必在代码中硬编码 HTML,例如:

    output.Write("

    content
    ");

自定义服务器控件具有前两个,但它们没有 ascx 文件,因此您必须将所有 html 代码写入 cs 文件中,

请告知...

I'm an expert web developer knowing all famous web frameworks.

I want to build a collection of Server Controls like ComponentArt components that you can use in your projects.

In ComponentArt: You can easily register the namespace of componentart in your project and bind data to those controls without any additional code or effort (like copying any additional files to our sample projects) and ofcourse they support ajax.

To accomplish this I came to realize that I have to develop some advanced UserControls that support callbacks for handling ajax and there are not much of a information about sharing UserControls amongst different projects. Actually here is the only useful link: http://www.codeproject.com/KB/user-controls/EmbeddedUserControl.aspx

On the other hand Server Controls don't have ascx template interfaces that I can comfortably design my control layouts.

I need a way to develop some web components that you can:

  1. Share amongst other projects easily (Just add dll to project and start
    using it)
  2. Support CallBack For ajax(for example ICallbackEventHandler)
  3. Can have a Template for HTML Design (like UserControl that have ascx template
    file) so you don't have to hardcode HTML in your code like:

    output.Write("<table>content</table>");

Custom Server Controls have the first two, but they don't have ascx files so you have to write all of your html code inside your cs file

Please advise...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风筝在阴天搁浅。 2024-10-14 12:51:04

您可以让服务器控件从文件中读取 HTML,而不是对 HTML 进行硬编码,该文件的名称和路径由您根据配置设置或目录路径确定。这将使您的服务器控件更加动态,并且无需在更改 HTML 时重新编译。这将有助于满足条件 #3,但成本比条件 #1 稍低(因为您的服务器控件现在依赖于外部资源,因此不太容易分发)。您始终可以对默认标记进行硬编码,如果找不到文件,则可以回退到它,作为针对异常的额外预防措施。

Instead of hard coding your HTML you could have your Server Controls read it from a file, whose name and path you determine based on a configuration setting or the directory path. That would allow your Server Controls to be more dynamic and not have a need for recompiling upon changing the HTML. That would help fulfill condition #3 at a slight cost to #1 (since your Server Control now relies on an outside resource it's not as easily distributable). You could always hard code the default markup and fall back to it if the file is not found as an extra precaution against exceptions.

惟欲睡 2024-10-14 12:51:04

要求 1 和 3 是互斥的。标记必须来自某个地方——要么是编译的资源,要么是外部文件。您的外部文件可以是可选的,但是您必须在编译的资源中指定默认标记。编译的资源不一定是您的 .cs 文件。您可以将其放入资源文件中,但我不确定这是否会更容易使用。您还可以将控件构建为现有服务器控件的组合,但这将使您的模板化变得更加困难。

Requirements 1 and 3 are mutually exclusive. The markup has to come from somewhere--either a compiled resource or an external file. Your external file could be optional, but then you have to have default markup specified in the compiled resource. The compiled resource doesn't necessarily have to be your .cs file. You could put it in a resource file, but I'm not sure that's going to be any easier to work with. You could also build your control as a composite of existing server controls, but that's going to make your templating much more difficult.

感情洁癖 2024-10-14 12:51:04

您需要开始通过以下书籍进行自我教育:

alt text

使用这本书,花了很多时间,我创建了一个多列树视图。可以在此处查看。

You need to start educating yourself with books like:

alt text

Using this book, and a lot of time, I created a multi column TreeView. Can be seen HERE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文