这里面的{0}表示什么意思?

解决方案 »

  1.   

    控件的标记的前缀<winner:DataGrid ID=winner2050 runat="BOBAMEI" />
      

  2.   

    下面就以,.net自动生成的模版做一解释。(以vb语言为例)1.Imports System.ComponentModel2.Imports System.Web.UI3.<DefaultProperty("Text"), ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")> Public Class WebCustomControl14.    Inherits System.Web.UI.WebControls.WebControl5.    Dim _text As String6.    <Bindable(True), Category("str"), DefaultValue("11111")> Property [Text]() As String7.         Get8.            Return _text9.         End Get10.        Set(ByVal Value As String)11.            _text = Value12.        End Set13.    End Property14.    Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)15.        output.Write([Text])16.    End Sub17.End Class'---------------------------------------------------------------'1-2 导入命名空间,System.ComponentModel和 System.Web.UI 这没什么好介绍的'3 DefaultProperty("Text")--指定属性的默认值。如果用此属性需要导入(命名空间: System.ComponentModel)ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")指定当从 Visual Studio 等工具中的工具箱拖动自定义控件时为它生成的默认标记。在下面的示例中,设置特定于 MyLabel 的若干属性。{0} 的所有匹配项都由设计器替换为与 MyLabel 类关联的标记前缀。<ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow' BackColor='Magenta' BorderWidth = '10'  runat='server'></{0}:MyLabel>")>Public Class WebCustomControl1定义类名为webcustomcontrol1,以后编译生成的dll名为webcustomtrol1(注意:如果你修改类名。则需要修改{0}:后相对应的名字。例如:你把类名webcustomcontrol1改为webcustom。则需要把ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")改成ToolboxData("<{0}:webcustom runat=server></{0}:webcustom>") 否则编译后将出错。)'4 Inherits 表示继承。这里是继承System.Web.UI.WebControls.WebControl的方法,属性,事件等。'6 这句主要是控制自定义控件在’属性浏览器‘中的显示,先解释模版的句子,再扩展开讲Property [Text]() As String定义 text属性 为字符串类型Bindable(True)指定是否要绑定到该属性。-True为是,False为不Category("Appearance") --text属性将显示在外观组中。指定类别的名称,在该类别中将对属性或事件进行分组。当使用了类别时,组件属性和事件可以按逻辑分组显示在属性浏览器中。DefaultValue("")为属性设置一个简单的默认值。这里为空