I want to select a certain area of a TextBox control in asp.net WebForms application.
The situation is that the textbox contains email addresses seperated by ;
. I wrote a little MailValidator class that sorts out valid and invalid email addresses.
Now i want the wrong email address to be selected, so that the user can correct it right away. As i mentioned, I know which addresses are valid and which aren't.
How do I do that?
I know how to select the whole text with .Focus()
(works at least in IE, and that's enough)
But how can I only select a certain area?
Is TextBox.Text.Select<>
the way to go? If so, can someone provide an example?
I don't fully understand what .Select<>
actually does.
TextBox.Text.Select<>
is not for selecting perticular text inside a textbox..Select<>
is a projection operator that can be applied to any list or array. SinceTextBox.Text
returns aString
i.e. a array ofchar
type, so you are seeingSelect<>
in VS intellisence. It has nothing to do with selecting textbox data. So don't be cofused with that! – Sanjeev Rai Jun 13 '13 at 7:16