如何重写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;
}
}
}