ASP.NET自定义控件 - 复合材料 [英] ASP.NET Custom Controls - Composites

查看:157
本文介绍了ASP.NET自定义控件 - 复合材料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
OK,再进入我的冒险与自定义控件...

Hi All,
OK, further into my adventures with custom controls...

总之,这里是我学到的三大类的自定义控件。请随时纠正我,如果任何这是错误的!

In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong!

  1. 用户控件 - 这从的用户控件的继承和被包含在一个 ASCX 的文件。这是pretty的限制,他们可以做什么,但一个快而轻的方式来获得与设计师的支持,一些UI共性。
  2. 自定义复合控件 - 这些是从的的WebControl 的,你添加pre-现有控件来控制范围内的的CreateChildControls 方法。这提供了很大的灵活性,但缺少设计师支持,而无需额外的编码。它们是高度便携的,虽然,因为它们可被编译成一个DLL。
  3. 自定义渲染控制 - 类似于自定义复合控件,这些被添加到Web控件库项目。控件的绘制是完全由编程控制的覆盖的渲染的方法。
  1. UserControls - Which inherit from UserControl and are contained within an ASCX file. These are pretty limited in what they can do, but are a quick and light way to get some UI commonality with designer support.
  2. Custom Composite Controls - These are controls that inherit from WebControl where you add pre-existing controls to the control within the CreateChildControls method. This provides great flexibility, but lack of designer support without additional coding. They are highly portable though since they can be compiled into a DLL.
  3. Custom Rendered Controls - Similar to Custom Composite Controls, these are added to a Web Control Library project. The rendering of the control is completely controlled by the programmer by overriding the Render method.

好了,而定制的复合材料打,我发现了以下内容:

My Thoughts..

OK, so while playing with custom composites, I found the following:

  • 您已经小/过HTML输出没有控制使其难以调试。
  • 的CreateChildControls 的(以及随后的方法)可以得到真正忙碌的 Controls.Add被(myControl)的无处不在。
  • 在我发现渲染表(无论是布局还是内容)是相当尴尬的。
  • You have little/no control over the HTML output making it difficult to "debug".
  • The CreateChildControls (and subsequent methods) can get real busy with Controls.Add(myControl) everywhere.
  • I found rendering tables (be it for layout or content) to be considerably awkward.

所以,我承认,我是新来这个,所以我可以的路要走基地与我的一些分以上。

So, I admit, I am new to this so I could be way off-base with some of my points noted above..

  • 请您使用复合材料?
  • 你有什么巧妙的技巧来控制HTML输出?
  • 请你刚才说管它呢,并继续创建一个自定义呈现控制?

它的东西,我很希望得到真正的公司在我的脑海里,因为我知道有多少的的控制开发可以减少整体开发时间。

Its something I am keen to get really firm in my mind since I know how much good control development can cut overall development time.

我期待着你的答案^ _ ^

I look forward to your answers ^_^

推荐答案

我说与自定义渲染控制前进。我发现,在大多数情况下,复合材料可以更容易完成,并在用户控件使用,但除此之外,任何事情,你需要有更好的控制度(双关语意外),值得你自己的渲染策略。

I say go ahead with the custom rendered control. I find that in most cases the composite can be easier done and used in a UserControl, but anything beyond that and you'd need to have a finer degree of control (pun unintended) to merit your own rendering strategy.

有可能控制是足够简单,值得复合材料(例如,一个文本框加上一个JavaScript / DHTML的基础日期选择器,例如),但除此之外的一个例子,它看起来像自定义绘制控件的路要走。

There maybe controls that are simple enough to merit a composite (e.g., a textbox combined with a javascript/dhtml based datepicker, for example) but beyond that one example, it looks like custom rendered controls are the way to go.

这篇关于ASP.NET自定义控件 - 复合材料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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