This is a migrated thread and some comments may be shown as answers.

TextBox Does Not Fire Events!

1 Answer 126 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Onur Tezic
Top achievements
Rank 2
Onur Tezic asked on 17 Dec 2009, 06:00 PM
Hi All,

I have created a class which inherits from RADTextBox and override the OnKeyPress() method.

public class RegExpRadTextBox : RadTextBox
{
string _keyRegExp;
public string KeyRegExp
{
get { return this._keyRegExp; }
set { this._keyRegExp = value; }
}

protected override void OnKeyPress(KeyPressEventArgs e)
{
if (!string.IsNullOrEmpty(this._keyRegExp))
{
if (!Regex.IsMatch(e.KeyChar.ToString(), this._keyRegExp))
{
e.Handled = true;
}
}

base.OnKeyPress(e);
}
}

But when i type some text, nothing happens (Keypress Event Firing/Raised).

(Keydown is also doesnt work.) 

What should i do? 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 21 Dec 2009, 10:09 AM
Hi Onur Tezic,

Thank you for your question. This happens because we are using a Microsoft TextBox inside RadTextBox. When you press a key, the microsoft text box is focused and it gets the key down / pressed notification, not RadTextBox. You should be able to implement your functionality with the help of TextChanging and TextChanged events that RadTextBox provides.

Kind regards,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
TextBox
Asked by
Onur Tezic
Top achievements
Rank 2
Answers by
Victor
Telerik team
Share this question
or