I want to perform Trim()
method on each TexBox
control on my page, before value is returned. I dont' want to hard-code the same code for each TexBox control, I want to do it in more elegant way.
I've found made the following class
namespace System.Web.UI.WebControls
{
public partial class TrimmedTextBuox : TextBox
{
private string text;
public override string Text
{
get { return string.IsNullOrEmpty(text) ? text : text.Trim(); }
set { text = value; }
}
}
}
but it fails, while debuggind the compiler doesn't get inside get{}
and set{}
.
After that, I created a UserControl
item, but it must be deriverd from System.Web.UI.UserControl
, not System.Web.UI.WebControls.TextBox
to get it work (there's an exception which points to that)
So, how can I do that ?