M| 学习写控件:第八贴: 怎么让小弟我的控件的拖到页面的时候会显示小弟我的控件的某一个属性 多谢

M| 学习写控件:第八贴: 如何让我的控件的拖到页面的时候会显示我的控件的某一个属性 谢谢
就像VS控件一样拖一个Label到页面的时候会默让显示Text如果Text没值时显示ID
然后我的控件我想让他默认显示MyMessage
要怎么做

谢谢

------解决方案--------------------
xxx.ascx.cs里面写
prviate String _myMessage

public String MyMessage
{
get
{
return _myMessage;
}
set
{
_meMessage = value;
}
}
------解决方案--------------------
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace WebControlLibrary1
{
/// <summary>
/// WebCustomControl1 的摘要说明。
/// </summary>
[DefaultProperty( "MyText "),
ToolboxData( " <{0}:WebCustomControl1 runat=server> </{0}:WebCustomControl1> ")]
public class WebCustomControl1 : System.Web.UI.WebControls.Label
{
private string text;

[Bindable(true),
Category( "Appearance "),
DefaultValue( " ")]
public string MyText
{
get
{
return text;
}

set
{
text = value;
}
}

/// <summary>
/// 将此控件呈现给指定的输出参数。
/// </summary>
/// <param name= "output "> 要写出到的 HTML 编写器 </param>
protected override void Render(HtmlTextWriter output)
{
output.Write(MyText);
base.Render(output);
}
}
}

------解决方案--------------------
[Bindable(true),
Category( "Appearance "),
DefaultValue( "这里加默认值 ")]
------解决方案--------------------
这个方法是描述控件的外观(用HTML描述) 因为你只需要出来默认的是一个你的属性 所以不用重写 只用加一下output.Write(MyText);
但你要的要求的话就必须重新写 不能用base.Render(output) 这是基类的方法
你现在不能用基类的方法了就 你就要自己描述了 我就不会了 难啊 等幕白来吧 我跟着学 呵呵



------解决方案--------------------
留个 回头看看
------解决方案--------------------
Bindable(true),
Category( "Appearance "),
DefaultValue( "这里加默认值 ")]
这个不行吗?
------解决方案--------------------
看看..
------解决方案--------------------

[
ToolboxData( " <{0}:WebCustomControl1 Text= ' ' runat=server> </{0}:WebCustomControl1> ")
]


------解决方案--------------------
sf上的那个正解
------解决方案--------------------
大概

[Browsable(true),
PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)
]
public int Text
{
get { return _text; }
set {
if(_text == " ")
{
_text = _ID;
}
else
{
_text= value;
}
}
}