在Page_Load中加
yourControl.Attributes.Add("onkeydown", "javascript:if(event.keyCode==13) event.keyCode=9;");
yourControl.Attributes.Add("onkeydown", "javascript:if(event.keyCode==13) event.keyCode=9;");
解决方案 »
- ASPNET用户能启动WINWORD.EXE进程却打不开word文档
- 本地测试没问题, EXCEL上传到万网服务器可以,但是读取数据到EXCEL出错!! 请看我的代码帮忙.
- 大家给我一个asp.net上传图片的例子
- asp.net级后的问题,有人遇到过吗?
- 如何获取每条记录在DataList控件中的索引值?
- asp.net操作oracle的日期查询问题?
- 如何实现图片的上传和下载?[至急] [在线等]
- LinkButton调用的JS函数可以用数据源的绑定字段吗???
- cs文件中的属性如何关联aspx界面中的控件值
- 为什么提示我“ 命名空间并不直接包含诸如字段或方法之类的成员”???看看我的程序!谢谢
- 求一个日期的函数
- 读写注册表的权限问题
能不能直接定义KEYPRESS事件,而不是针对某个控件呢
if(getKEYCODE(e)==13){
if(document.Form1.elements[document.Form1.elements.length-1].name == window.event.srcElement.name)
{
document.Form1.cboBusiness_Nm.focus();
window.event.returnValue = false;
} else
{
window.event.keyCode = 9;
}
}
else{
if(getKEYCODE(e)==8){
window.event.returnValue = false;
}
else{
if(getKEYCODE(e)==9 && event.shiftkey){
if(document.Form1.elements[document.Form1.elements.length-1].name == window.event.srcElement.name)
{
document.Form1.elements[3].focus();
window.event.returnValue = false;
}
}
}
}
}
function getKEYCODE(e){
if(document.layers) return e.which //netscape4
else if(document.all) return event.keyCode //Ie4,Ie5,Ie6
else if(document.getElementById) return e.keyCode //netscape6,moz
}
function eventStart(startName){
self.focus()
document.Form1.all(startName).focus();
document.onkeydown = focusToNext
if(document.layers)document.captureEvents(Event.KEYDOWN)
}
function focusToNext(e){
if(getKEYCODE(e)==13)
nextElement.focus()
}
function getKEYCODE(e){
if(document.layers) return e.which //netscape4
else if(document.all) return event.keyCode //Ie4,Ie5,Ie6
else if(document.getElementById) return e.keyCode //netscape6,moz
} function eventStart(){ self.focus()
document.onkeydown=focusToNext
if(document.layers)document.captureEvents(Event.KEYDOWN)
}
我使用的环境是VB.net
<SCRIPT LANGUAGE='JScript'>
document.onkeydown=document_keydown;
function document_keydown()
{
//form中回车代替TAB键
if(window.event.srcElement.value!='保存'&window.event.srcElement.type!='textarea'&event.keyCode==13)
{
event.keyCode=9;
onsubmit='return false;'
}
}
</script>