<script language="javascript" type="text/javascript"> //the purpose of this function is to allow the enter key to 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) { //If we find the button click it btn.click(); event.keyCode = 0 } } } </script>
protected void Page_Load(object sender, EventArgs e) { // if (!IsPostBack) if (!this.IsPostBack) { Control myLoginButton = Login1.FindControl("LoginButton"); if (myLoginButton != null && myLoginButton is IButtonControl) { Login1.Attributes.Add("onKeyPress", "doClick('" + myLoginButton.ClientID + "',event)"); } } }
<form id="form1" runat="server" defaultbutton="LoginButton"> </form>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)