如何让Visual Studio.net 2003 智能感知自定义属性

有时候我们开发了一个web框架,并且这个框架需要给控件加入框架特有的属性才能正确运行,但是vs.net不能够智能感知这些新的属性,在新属性比较多时,就会给开发带来一定的麻烦。怎样才能让vs.net识别这些新的属性呢?

可以通过修改 <Visual Studio installation folder>\Common7\Packages\schemas\xml\asp.xsd 文件,来达到我们的目的。
效果如下图:

例如,想让asp:CheckBox 增加 zbind属性,先找到asp:CheckBox的定义,如下:

<!--  <asp:CheckBox>  -->

< xsd:complexType  name ="CheckBoxDef"  vs:noambientcontentmodel ="true" >
  
< xsd:attribute  name ="AutoPostBack"  type ="xsd:boolean"   />
  
< xsd:attribute  name ="Checked"  type ="xsd:boolean"   />
  
< xsd:attribute  name ="Text"  type ="xsd:string"   />
  
< xsd:attribute  name ="TextAlign"  type ="TextAlign"   />
  
< xsd:attribute  name ="OnCheckedChanged"  vs:omtype ="event"   />
  
< xsd:attribute  name ="Enabled"  type ="xsd:boolean"   />
  
< xsd:attribute  name ="BorderWidth"  type ="ui4"   />
  
< xsd:attribute  name ="BorderColor"  type ="xsd:string"  vs:builder ="color"   />
  
< xsd:attribute  name ="BorderStyle"  type ="BorderStyle"   />
  
< xsd:attributeGroup  ref ="WebControlAttributes"   />
</ xsd:complexType >
然后在节点 </ xsd:complexType >上面,添加下面的语句:
<xsd:attribute name="zbind" type="xsd:string"/>


如果按这种方法修改,我们自定义的标签就可以得到智能提示,Web框架的用户将会得到更好的易用性。
另外, 也可以定义枚举类型,下面定义的是 HorizontalAlign 类型,智能提示为: Left Center Right Justify
< xsd:attributeGroup  name ="TableCellAttributes" >

  
< xsd:attribute  name ="VerticalAlign"  type ="VerticalAlign"   />

  
< xsd:attribute  name ="RowSpan"  type ="xsd:integer"   />

  
< xsd:attribute  name ="ColumnSpan"  type ="xsd:integer"   />

  
< xsd:attribute  name ="HorizontalAlign"  type ="HorizontalAlign"   />

  ….

</ xsd:attributeGroup >

 

< xsd:simpleType  name ="HorizontalAlign" >

  
< xsd:restriction  base ="xsd:string" >

    
< xsd:enumeration  value ="NotSet"   />

    
< xsd:enumeration  value ="Left"   />

    
< xsd:enumeration  value ="Center"   />

    
< xsd:enumeration  value ="Right"   />

    
< xsd:enumeration  value ="Justify"   />

  
</ xsd:restriction >

</ xsd:simpleType >


转载于:https://www.cnblogs.com/northdevil/archive/2007/10/26/938565.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值