ASP
本类阅读TOP10
作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站
显然,这个Control什么都做不了。写它的目的是为了追踪System.Web.UI.Design.ControlDesigner.GetDesignTimeHtml()究竟做了什么事。编译->放到工具箱->启动另一个IDE->创建一个Web应用程序->回到控件编辑的IDE->启动进程监视->设置断点(断点位置见代码)->回到Web应用程序IDE->把SimpleControl扔到Webform1里然后你发现了什么?对,没错,DesignTimeHtml的Get流程:首先,IDE检查SimpleControlDesigner的GetDesignTimeHtml(),然后根据SimpleControlDesigner.GetDesignTimeHtml()指示,调用base.GetDesignTimeHtml(),也就是System.Web.UI.Design.ControlDesigner的GetDesignTimeHtml()那么ControlDesigner的GetDesignTimeHtml()做了什么呢?原来它和运行时刻一样(其实还是有一些区别的,我以后再详细解释),搞了一个HtmlTextWriter,请求SimpleControl.Render()生成Html,以便在IDE里显示。至此,我们可以发现,除了自己一行行的拼凑外,也可以让控件本身的Render()来生成DesignTimeHtml。
抛弃GetDesignTimeHtml()现在来做个不需要实现GetDesignTimeHtml()方法,或者连ControlDesigner都不用,却能提供丰富灵活的DesignTime呈现的WebControl
设计时效果:图中控件的属性为
相关软件: