How do I associate the Enter key with a button on an ascx page?
I have a button on one of my content pages which i need to fire on hitting the enter button. I tried specifying the default button in the updatepanel but without any avail. If you have 开发者_如何学JAVAa solution for the same please let me know. Thanks in advance.
Use the panel control and setup your button with DefaultButton="Button1"
<asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
.................................
...............your contents..................
</asp:Panel>
You can also use javascript, which you can call from the textbox's key press event,
function checkKey(b1, e) {
if (e.keyCode == 13) {
document.getElementById(b1).click();
return false;
} }
Hope this will helps...
精彩评论