复制代码 代码如下:
function EnterTextBox(e)
{
var msie = (document.all) ? true : false;
var keycode;
if(!msie) keycode = window.event ? e.keyCode : e.which;
else keycode = e.keyCode;
//alert(keycode);
if(keycode==13 && document.getElementById('<%=this.txtSearch.ClientID%>').value != "")
{
//alert("test");
if(msie)
{
e.keyCode = 9;
e.returnValue = false;
}
document.getElementById('<%=this.btnSearch.ClientID%>').click();
}
}
复制代码 代码如下:
protected override void OnPreRender(EventArgs e)
{
txtSearch.Attributes.Add("onkeypress", "EnterTextBox(event);")
}
复制代码 代码如下:
<HEAD>
<script language="javascript">
function EnterTextBox()
{
if(event.keyCode == 13 && document.all["TextBox1"].value != "")
{
event.keyCode = 9;
event.returnValue = false;
document.all["Button1"].click();
}
}
</script>
</HEAD>
<body onkeypress="return EnterTextBox()">
复制代码 代码如下:
<HEAD>
<script language="javascript">
function EnterTextBox(button)
{
if(event.keyCode == 13)
{
event.keyCode = 9;
event.returnValue = false;
document.all[button].click();
}
}
</script>
</HEAD>
复制代码 代码如下:
<fieldset>
<legend [查詢條件]</legend>
<table>
<tr><td>
<asp:TextBox runat="server"></asp:TextBox></td>
</tr>
<tr>
<td >
<asp:Button runat="server"/></td>
</tr>
</table>
</fieldset>
新闻热点
疑难解答
图片精选