Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Default ENTER key press to button click event
Message
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
00872282
Message ID:
00872609
Views:
25
Hi Neil,

I just created a sample app with one textbox and two buttons. Using the technique below, it worked as expected. I'm not sure what you are doing different.

>Thank you Cathi,
>
>This works great when your web form contains more than 1 texbox. I however have 2 web forms that only contain 1 texbox each. I need a technique to default the ENTER key to activate a button's click event on web forms that only have 1 textbox.
>
>Neil
>
>>Hi Neil,
>>
>>The C# version would just have a semicolon after the line.
>>
>>>That is wild. Thank you. Any chance at a c# incarnation or is it basically the same?
>>>
>>>Neil
>>>
>>>>I found this code here long time ago:
>>>>
>>>>
>>>>   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
>>>>
>>>>        ' This causes the page to associate Enter key with cmdAddIt button click event.
>>>>        ' (source: Universal Thread Message ID: 814613, http://www.levelextreme.com)
>>>>        Page.RegisterHiddenField("__EVENTTARGET", "cmdAddIt")
>>>>
>>>>    End Sub
>>>>
>>>>
>>>>
>>>>Also, take a look at thread 849502
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>I have a web form with a 2 buttons: CLOSE (btnClose) and SAVE (btnSave). I would like the ENTER key on the keyboard to fire the click event of the SAVE button. What property do I set to make the ENTER key the default. OR... do I need to include a method in an event handler.
>>>>>
>>>>>Regards,
>>>>>Neil
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform