Author: andieje | Posted on: 11/23/2008 11:31:37 AM | Views : 283

Hello

I am using asp.net 2.0. Please bear with me as i haven't programmed for about a year.

I would like a page that contains one textbox and a button. I would like the page to be submitted when the user presses enter in the textbox and when the user clicks the button. I want different actions to be performed depending on whether the user pressed the button or pressed enter. I know i can get code to be performed in the click event of the button but how can i get code to be executed only if the user pressed enter. The best i can think of is to have a flag called enterPressed which is set to true when the page loads. If the click event is executed then enterPressed is set to false. Then in the preRender event i have some code like

if enterPressed then
    execute code for Enter
end if

 is there anything better?

many thanks
...

Go to the complete details ...