Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

ASP page submit uses wrong button click event

Modified: 2009/11/20 17:08 by jim - Categorized as: ASP.NET, Visual Studio
Problem: A search page with two asp:button objects. The first ones click event navigates to a random page, the second one submits a search query and returns a search result. Several asp:textbox objects hold the search criteria. A user enters some criteria, then hits the Enter key on his keyboard; the page submit uses the click event of the first button, not our search button.

Solution: asp:button have a property UseSubmitBehaviour (true/false). Set it to false for all the buttons except the one u want to have it's event fired when the user hits the enter key.

Reason: a web page with at least on textbox fires the click event of the button that is rendered first in the HTML.


 © Evident Interactive BV