R
Radu
Hi. I have the following problem - I need to build a user-control in
asp.net (an ascx) to somehow allow the users to search by first name
or last name among a big (~10.000 records) email addresses database
(SQL server table). I am thinking of allowing them to type something
in EITHER the last name, EITHER the first name textbox, and on each
text change to show in a combobox the records starting with that
letter combination.
Say for example that you have the following email addresses:
Hardy
John Doe
John Foe
John Poe
Johny Roe
Johny Zoe
Laurel
......
When you type in the FirstName textbox the string "John", the combo
box should position itself on John Doe. Hardy should still be visible
right above John Doe, if you open the combobox, but John Doe should be
selected. If you type Johny, it should position itself onto Johny Roe.
If you type Johnson, it should show the first element of the combobox,
a null string, since there is no Johnson in the list.
Similar functionality for the LastName textbox.
Finally, when you are happy with the selection in the combobox, say
"Johny Roe", you click a 'Search' button which will populate the
search form with Johny Roe's ID.
My problem is that I don't know how to best implement this. I'm
thinking of tying somehow keypresses with some server code which will
interogate the SQL server database. I'm afraid of the reaction time of
this control, though.
Question: How do I associate code with keypresses ? I can't use
Javascript for this, because I need to look up the string into SQL
tables on the server, and a textbox has only a TextChanged event.
Although I know how to write the server code, I still don't know how
to do this overall - and still I have seen something like that before,
and it worked great, and super-fast - actually I don't know if it
involved trips to the server, although I guess it did.
Do you have any advice, please ? Thank you very much !
Alex. Nitulescu
asp.net (an ascx) to somehow allow the users to search by first name
or last name among a big (~10.000 records) email addresses database
(SQL server table). I am thinking of allowing them to type something
in EITHER the last name, EITHER the first name textbox, and on each
text change to show in a combobox the records starting with that
letter combination.
Say for example that you have the following email addresses:
Hardy
John Doe
John Foe
John Poe
Johny Roe
Johny Zoe
Laurel
......
When you type in the FirstName textbox the string "John", the combo
box should position itself on John Doe. Hardy should still be visible
right above John Doe, if you open the combobox, but John Doe should be
selected. If you type Johny, it should position itself onto Johny Roe.
If you type Johnson, it should show the first element of the combobox,
a null string, since there is no Johnson in the list.
Similar functionality for the LastName textbox.
Finally, when you are happy with the selection in the combobox, say
"Johny Roe", you click a 'Search' button which will populate the
search form with Johny Roe's ID.
My problem is that I don't know how to best implement this. I'm
thinking of tying somehow keypresses with some server code which will
interogate the SQL server database. I'm afraid of the reaction time of
this control, though.
Question: How do I associate code with keypresses ? I can't use
Javascript for this, because I need to look up the string into SQL
tables on the server, and a textbox has only a TextChanged event.
Although I know how to write the server code, I still don't know how
to do this overall - and still I have seen something like that before,
and it worked great, and super-fast - actually I don't know if it
involved trips to the server, although I guess it did.
Do you have any advice, please ? Thank you very much !
Alex. Nitulescu