CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

您现在的位置: IT专家网 > Web服务子站 > 技巧

探讨ASP.NET 2.0中的Web控件改进技术

作者: 朱先忠 编译,  出处:天极, 责任编辑: 叶江, 
2007-01-30 11:15
  ASP.NET 2.0并没有抛弃1.1版本中的任何现有控件,而是增加了一组新的控件;同时还引入了若干新的控件开发技术。本系列文章将对这些内容展开全面探讨。

  你可能已经猜出,对于你想定义的每个模板和每个模板组,都要重复这一操作。最终结果是,我的o_TemplateGroups对象中填充了我的模板中定义的所有信息—而这正是我在这个属性中所返回的内容。

  图3.在模板编辑方式的EmailContact控件

  现在,我重新编译并转到我的测试页面。当我右击EmailContact控件时,我将看到“EditTemplates”被添加到快捷方式菜单中。子菜单下的列表将显示我在设计器类中所定义的模板组,而当我选择“Surrounding Templates”组时,我会看到类似图3所示的内容。现在,你可以看到我手工地添加到这两个模板中的控件;而事实上,我现在就可以把其它控件从工具箱直接拖动到其上。再次右击鼠标并选择“Edit Templates”将返回到标准控件视图并且在控件中显示该模板内容。

  另外还注意,一个“Edit Templates”链接也被自动地添加到该控件的灵敏标签上。如果以前不存在一个灵敏标签,那么,当我把模板编辑代码添加到设计器类上时,它会自动地为我创建一个。

  下面是完整的模板编辑代码:

  Public Overrides Sub Initialize(ByVal Component As IComponent)
  MyBase.Initialize(Component)
  ' Turn on template editing
  SetViewFlags(ViewFlags.TemplateEditing, True)
  End Sub
  Private o_TemplateGroups As TemplateGroupCollection = Nothing
  Public Overrides ReadOnly Property TemplateGroups() _
  As TemplateGroupCollection
  Get
  If o_TemplateGroups Is Nothing Then
  o_TemplateGroups = New TemplateGroupCollection()
  Dim o_TemplateGroup As TemplateGroup
  Dim o_TemplateDefinition As TemplateDefinition
  Dim ctl As EmailContact2 = CType(Component, _
  EmailContact2)
  o_TemplateGroup = New TemplateGroup( _
  "Surrounding Templates")
  o_TemplateDefinition = New TemplateDefinition( _
  Me, "Header Template", ctl, "HeaderTemplate", True)
  o_TemplateGroup.AddTemplateDefinition( _
  o_TemplateDefinition)
  o_TemplateDefinition = New TemplateDefinition( _
  Me, "Footer Template", ctl, "FooterTemplate", True)
  o_TemplateGroup.AddTemplateDefinition( _
  o_TemplateDefinition)
  o_TemplateGroups.Add(o_TemplateGroup)
  End If
  Return o_TemplateGroups
  End Get
  End Property
共14页。 9 5 6 7 8 9 10 11 12 13 14 :

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅

       
天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错
All Rights Reserved, Copyright 2004-2008, Ctocio.com.cn
渝ICP证B2-20030003号 如有意见请与我们联系 powered by 天极内容管理平台CMS4i