Tips for writing ASP.NET composite controls

原创 2004年10月22日 17:39:00
Here are some tips I picked up in a Microsoft newsgroup regarding the creation of composite ASP.NET web controls.

1) My composite controls are created based on a property of my control. When the postback of a page occurs due to a button click, my CreateChildControls() method is called before the button code is executed, so if that button code changes the property in question it is already too late to reflect this in the control. Is there a way to "Invalidate" my control when this property is set so that it's child controls are recreated?

A) Yes, set ChildControlsCreate to false.

2) Dropping my control onto a design surface displays only a blank control, none of the composite controls are visible at all.

First add the following method in order to expose the functionality of a protected method in your component

public new void EnsureChildControls()

Next add the following attribute to your class

Finally, create a designer class like so

public class MyControlDesigner : ControlDesigner


public override String GetDesignTimeHtml()


( (MyControl) Control).EnsureChildControls();

return base.GetDesignTimeHtml();



Writing Tips

Writing Tips “Either write something worth reading, or do something worth writing.”  -- Benjamin F...
  • likaidlut
  • likaidlut
  • 2014年02月19日 12:06
  • 805


public class Mytest {     private static ApplicationContext applicationContext;     public sta...
  • yang123111
  • yang123111
  • 2014年06月25日 14:37
  • 3167

小 页面中的注释

在 2.0中,在页面HTML部分,可以使用服务端注释server comments,那样是不会将所注释的内容回传到客户端的,做一个对比下面                   Ser...
  • jackyrongvip
  • jackyrongvip
  • 2006年08月25日 16:22
  • 535


ASP.NET2.0轻松搞定统计图表 作者:清清月儿 主页:           时间:2007.3.27本文讲述如何绘制条形图,折线图,柱...
  • 21aspnet
  • 21aspnet
  • 2007年03月27日 22:16
  • 40818


AutoRun.inf  命令(翻译MSDN)这篇文档是在AutoRun.inf文件中命令的介绍 [AutoRun]命令:l         Iconl         Labell         ...
  • xuweii
  • xuweii
  • 2006年06月22日 17:13
  • 6391

SIGIR Paper Writing Tips

SIGIR Paper Writing Tips by Peter Bailey is licensed under a Creative Commons Attribution-NonCommerc...
  • qiudw
  • qiudw
  • 2013年04月24日 20:51
  • 728

Essay Writing Tips

Get started early, you don't want to wait to the last minute and have to rush through your essay. W...
  • alangdangjia
  • alangdangjia
  • 2011年12月09日 19:40
  • 389


  • bigstoneasd
  • bigstoneasd
  • 2008年02月01日 09:19
  • 5319


  • chinalinuxzend
  • chinalinuxzend
  • 2008年08月06日 19:43
  • 4205

关于SWT中 composite 嵌套 composite 内容无法显示的问题解决办法

相关的讨论文章可以看该文章提出了采用 individualLeft.s...
  • bjtujavadwswt
  • bjtujavadwswt
  • 2009年08月30日 11:00
  • 802
您举报文章:Tips for writing ASP.NET composite controls