Asp.net 在输入时激活提交按钮
现在我必须单击Asp.net 在输入时激活提交按钮,asp.net,vb.net,webforms,Asp.net,Vb.net,Webforms,现在我必须单击Login按钮才能向服务器发送表单 我想在密码字段中按Enter键 代码如下: <%@ Page Language="VB" AutoEventWireup="False" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/
Login
按钮才能向服务器发送表单
我想在密码字段中按Enter键
代码如下:
<%@ Page Language="VB" AutoEventWireup="False" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Login Page</title>
<SCRIPT language="javascript" src="commonpages/js/Utility.js" type="text/javascript"></SCRIPT>
<script>
function GoBtn_ServerClick(oButton, oEvent) {
}
</script>
</head>
<body style="background-color:AliceBlue">
<div id="main0">
<!--<input id="auto" type=button value="Print test" onclick="Printtest();">-->
<table width=800 align=center height=600px style="background-color: AliceBlue;">
<tr>
<td width=25></td>
<td width=750 align=center><form runat="server">
<table ><tr><td colspan="2">
</td></tr>
<tr><td align=left>
Login:</td><td align=right>
<input id="login" runat=server type=text style="width: 100px"/></td>
</tr><tr><td align=left>
Password:</td><td align=right>
<input id="pw" runat=server type=password style="width: 100px"/>
</td></tr>
<tr><td align=center colspan=2>
<input type=button runat=server id=GoBtn value=Login style="width: 60" CausesValidation="False" />
</td></tr></table></form>
</td>
<td width=25></td>
</tr>
</table>
</div>
</body>
</html>
登录页面
功能GoBtn_服务器单击(对象按钮,oEvent){
}
登录:
密码:
我在Stack Overflow中搜索了类似的问题,但它们显示了使用ASP控件而不是HTML控件的示例。将GoBtn上的“type=button”更改为“type=submit”,当您按Enter键时应该会触发它 或者,当在密码字段中按Enter键时,可以使用jQuery“单击”按钮:
$(document).ready(function(){
$('#pw').keypress(function(e){
if(e.keyCode==13)
$('#GoBtn').click();
});
});