JavaScript works fine.
See :
http://www.allasp.net/enterkey.aspx You can use a slightly more native way to do this with :
SomeTextBox.Attributes.Add("onKeyPress",
"javascript:if (event.keyCode == 13) __doPostBack('" +
YourSubmitButton.UniqueID + "','')");
That should all go on one line...
"SomeTextBox" is the text box control,
while "YourSubmitButton" is the submit button.
The easiest way to get this behavior to work is to
include a hidden submit button anywhere in the page:
<input type="text" style="display:none">
Then, you don't need any Javascript at all.
I just added that line to the ASPNETFAQ.COM Search button.
Try it now. You'll see that hitting enter instead of clicking the "Search Now" works.
http://www.aspnetfaq.com/ It's just that I was swamped with more pressing issues.
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ :
http://asp.net.do/faq/ ASPNETFAQ.COM :
http://www.aspnetfaq.com/ Foros de ASP.NET en Español :
http://asp.net.do/foros/ ======================================
[quoted text, click to view] "Joe" <joeherro@donotspam.yahoo.com> wrote in message
news:C61D3915-FB29-414A-BF9C-0B844A733447@microsoft.com...
> Juan,
>
> Question about setting default behavior to Submit. Do you do this with
> JavaScript of is there a .NET way of accomplishing this behavior?
> --
> Joe
>
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
>
> "Juan T. Llibre" wrote:
>
>> Hey, guys.
>>
>> How about giving
http://www.aspnetfaq.com/ a test ride ?
>>
>> Especially, check out the search facility.
>> Make sure that you hit the Search button, though.
>> I have not yet set the default behavior to Submit when you hit enter.
>>
>> Also, check the selection by category and the FAQ selection by clicking on it.
>>
>> I will appreciate all feedback, as the site is going live within 24 hours.
>>
>> Thanks!
>>
>>
>>
>> Juan T. Llibre, ASP.NET MVP
>> ASP.NET FAQ :
http://asp.net.do/faq/ >> Foros de ASP.NET en Español :
http://asp.net.do/foros/ >> ======================================
>>
>>
>>