日期:2014-05-18  浏览次数:20477 次

如何重写TextBox的Text属性,需要示例
如何重写TextBox的Text属性,需要详细的完整的示例``SOS

------解决方案--------------------
public class MyTextBox : System.Web.UI.WebControls.TextBox
{
public override string Text
{
get { return base.Text; }
set
{
// 验证代码
// ...
// example validation case
if(value != "csdn ") thrown new Exception( "请输入小写的csdn ");
// ...
base.Text = value;
}
}
------解决方案--------------------
public class usertxtbox : System.Windows.Forms.TextBox
{
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
}
}

}