开发者

ModelPopupExtender and Enter key press

I'm using ModelPopupExtender for login popup. After I set De开发者_如何学GofaultButton for Panel that contain login button, it doesn't fire click event when I press Enter key.

Can you help me?


I got more success when I use JavaScript to simulate the Click event on the button when the enter key is hit :

here the script function.

<script type="text/javascript">
  function clickButton(e, buttonid) {
     //click on the button an enter key  
     var evt = e ? e : window.event;
     var bt = document.getElementById(buttonid);
     if (bt) {
        if (evt.keyCode == 13) {
            bt.click();
            return false;
        }
     }
  }
</script>

and here how I link the field to the function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        myTextbox.Attributes.Add("onkeypress", "return clickButton(event,'" + MyOkButton.ClientID + "')")
    End If
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜