hi people,
i am completely stuck trying to get the enter key to submit a search query after typing in a textbox. please help!!!
it sounds such a simple and obvious thing to do, its in software everywhere but for the life of me i can't find a simple answer for a newbie like myself to absorb. here's the scenario in pseudo code...
private sub searchBtn_click...
here's my working search code - reading contents from textbox1,
activates when the button is clicked
end sub
private sub textbox...
i want to know the code required for an enter keypress here, with the cursor still in this field, to submit any text in the text box to the search query i have written in the searchBtn_click event !!!
end sub
i may be thinking this completely wrong, so someone please steer me in the right direction. a knowledgable vb6 colleague of mine did this with very little code but the method he used does not work in vb.net.
cheers me hearties

enter key on textbox to run button click event????
DecentViv
got it - dead easy
sub myRoutine()
my code here..
end sub
then call myRoutine() again in the btnclick and keypress events - YAY!!!
baolsen
Sorry to interupt but..
What if you have many buttons binded to a specific point in the database and you want to update the database from the page. the desired reaction is to enter the number and it updates the database and this is set up to be for all fifty boxes.
On the page are many textboxes then:
I enter say 10 into the textbox and it displays the number and updates the database but the key here is to be able to save all the information on the enter command.
[is there something to do with upon page change or a more efficient way]
Shihan
mindcooler
Use the KeyDown event of your TextBox:
Private
Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyCode = Keys.Enter Then'do something here...
End IfEnd Sub
DanL43
this code does not work
Jim Svoboda
ok, i'm off to google calling subroutines up, but if it doesn't take much explaining i wouldn't mind a quick demonstration.
cheers you've been a great help (will look up the keypress_up thing too)
David_L
wicked that worked, though just did a quick test with a messagebox.
so, am i wrong to think that this keypress down could in effect call the routine i already have once, within my original buttonclick event how would i do that
i'm sure i shouldn't have to paste the search routine code into two different subs would the ideal situation be to have my search in its own subroutine, and then have the keydown and buttonclick events call upon it
forgive me i am a newbie and i think i'm about to be introduced to setting up calling subroutines
many thanks
Blue Gene
Ripster
Enishi69
Page.RegisterHiddenField("__EVENTTARGET", "YourButtonName")