trying to create a textbox that will count foreign chars as 2 bytes, then use tagmap in config to replace all textboxes in app. if textbox max length is set to 4, and you enter 3 foreign chars, .net considers 3 characters entered. i'm trying to override this behavior to say foreign chars are 2, ascii chars are one.
So if you enter 2 foreign chars, and 2 english chars, text.length is 6. problem is that length is readonly property, so i'm trying by setting text, but having trouble.
here's what i have so far:
public class TextBox : System.Web.UI.WebControls.TextBox
{
public override string Text
{
get
{
return base.Text;
}
set
{
// base.Text.Length = ASCIIEncoding.UTF8.GetBytes(value.ToCharArray()).Length; // compiler err that length is readonly
// base.Text = value;
}
}
protected override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
Page.ClientScript.ValidateEvent(this.UniqueID, string.Empty);
string _presentValue = this.Text;
string _postedValue = postCollection[postDataKey];
if (_postedValue.Length > this.MaxLength)
{
_postedValue = _postedValue.Substring(0, this.MaxLength);
}
if (!_presentValue.Equals(_postedValue))
{
this.Text = _postedValue;
return true;
}
return false;
//return base.LoadPostData(postDataKey, postCollection);
}
}
i think this might do it, still setting up test.
public class TextBox : System.Web.UI.WebControls.
{
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = ASCIIEncoding.UTF8.GetStri
}
}