Handle Enter Key on Website (ASP and VB)
So I have a website with multiple asp controls. When I press enter inside by login form, the search function runs because it's the first thing found on the page.
How would I handle the enter button so that when the active textbox is for the login form, the loginbutton code actually runs rather than the searchbutton.
One last problem is that the login controls are inside a loginview so the hierarchy shows that the asp:textbox and asp:button for logging in are inside 3 tags like so:
<logi开发者_JAVA技巧nview>
<login>
<logintemplate>
//controls are here.
</logintemplate>
</login>
Just a note that all controls are asp and that all code is prefered in VB. Thanks
You want to set the default button on the form like this:
Page.Form.DefaultButton = "LoginButtonId"
MSDN Docs: http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton%28VS.80%29.aspx
Also, see this question for an issue I had in Firefox related to this : Default Form Button in FireFox
精彩评论