When a person completes filling a form in the site, if the user presses on Enter key in the keyboard,
it should go to submit button by default. Is there any way I can make it happen?
Thanks
When a person completes filling a form in the site, if the user presses on Enter key in the keyboard,
it should go to submit button by default. Is there any way I can make it happen?
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
ArshadRank #2,492 · 564 reputationPosted Jan 11, 2009, 7:01 PM EST
function doClick(buttonName,e)
{
var key;
if(window.event)
{
key = window.event.keyCode; //IE
}
else
key = e.which; //firefox
if (key == 13)
{
var btn = document.getElementById(buttonName);
if (btn != null)
{
btn.click();
event.keyCode = 0
}
}
}
Regards
Khan.
r pRank #4,639 · 333 reputationPosted Jan 18, 2009, 11:06 PM EST
I created a Javascript function with the code which you have given me.
But, how should I call this?
Where should I call this?
I am using asp.net login control. Suppose the user hits on enter key immediately after entering the username,
it should go to the Submit button, Now, it is not going to the Submit button.
Any idea?
Thanks so much
ravi20 reputationPosted Jan 19, 2009, 10:05 AM EST
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jan 20, 2009, 3:58 AM EST
We can set Defaultbutton property either in Form or if we've placed a panel than in panel
or if we use panel than
r pRank #4,639 · 333 reputationPosted Jan 20, 2009, 10:34 PM EST
When I use
Invalid postback or callback argument. Event validation is enabled using
When I used runat="server", it did not work. So, I removed runat="server".
Should I use something else?
Thanks,
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jan 21, 2009, 11:05 AM EST
The default configurationenableEventValidation="true"/> to or
hinders changes made on the client to prevent XSS (Cross Site Scripting). If
you don't want this support you can change
set <%@ Page EnableEventValidation="true" %> to <%@ Page
EnableEventValidation="false" %> in the one page you want to allow changes
made to your dropdownlists. Be sure though to check EVERY value on the
server. Remember: ALL INPUT IS EVIL!!!
Now u can check the following code:
ASP.NET 2.0 makes this problems easier and introduce a concept of a "default button". New defaultbutton attribute can be used with
r pRank #4,639 · 333 reputationPosted Jan 22, 2009, 5:27 AM EST
But, I am getting an error like this:-
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the
same validationKey and validation algorithm. AutoGenerate cannot be used in a
cluster.
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jan 22, 2009, 8:55 PM EST
This error may occur when one hosts an ASP.NET webpage on a web-garden.
Simple solution (for ASP.NET 2.0 and up): Generate a new machinekey and add it to the web.config.
Try the following URL to generate machinekey:
http://www.aspnetresources.com/tools/keycreator.aspx
r pRank #4,639 · 333 reputationPosted Jan 22, 2009, 11:03 PM EST
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that
Thanks