Skip to content

Instantly share code, notes, and snippets.

@teamaton
Last active September 21, 2016 23:10
Show Gist options
  • Save teamaton/9cefacb47721baac8971124ba8ea513e to your computer and use it in GitHub Desktop.
Save teamaton/9cefacb47721baac8971124ba8ea513e to your computer and use it in GitHub Desktop.
A special-purpose TextBox derivative that automatically trims whitespace from its Text value.
/// LICENSE: MIT
using System.Web.UI.WebControls;
namespace Generic.Frontend.Web
{
public class TrimTextBox : TextBox
{
/// <summary>
/// Returns the text entered, but with leading and trailing whitespace removed.
/// </summary>
public override string Text
{
get { return base.Text.Trim(); }
set { base.Text = value; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment