Javascript 如何使用箭头键在ASP.NET Gridview中上下移动
我在Grid view controls ItemTemplate中有一个Grid view控件,我现在要做的是,按下向下箭头键,第一行第一个文本框中的光标将转到第二行的第一个文本框Javascript 如何使用箭头键在ASP.NET Gridview中上下移动,javascript,asp.net,Javascript,Asp.net,我在Grid view controls ItemTemplate中有一个Grid view控件,我现在要做的是,按下向下箭头键,第一行第一个文本框中的光标将转到第二行的第一个文本框 这是我想做的上下操作的网格视图使用这个URL,它带有代码。 $(文档).ready(函数(){ //仅获取带有类数据输入的输入标记 textboxs=$(“input.data entry”); //现在我们检查正在使用的浏览器 如果($.browser.mozilla){ $(文本框)。按键(checkFor
这是我想做的上下操作的网格视图使用这个URL,它带有代码。
$(文档).ready(函数(){
//仅获取带有类数据输入的输入标记
textboxs=$(“input.data entry”);
//现在我们检查正在使用的浏览器
如果($.browser.mozilla){
$(文本框)。按键(checkForAction);
}
否则{
$(文本框)。向下键(checkForAction);
}
});
函数checkForAction(事件){
如果(event.keyCode==13 | | 40){
currentBoxNumber=textboxs.index(此);
if(文本框[currentBoxNumber+1]!=null){
nextBox=文本框[currentBoxNumber+1]
nextBox.focus();
nextBox.select();
event.preventDefault();
返回false;
}
}
}
使用此URL,它包含代码。谢谢你的回复,这让我很高兴听到。请投票支持我的答案,并将其标记为答案。@st mnmn感谢您的支持…我正在尝试了解如何在网格视图中使用上下箭头移动…这是一个开始。
<script type="text/javascript">
$(document).ready(function(){
// get only input tags with class data-entry
textboxes = $("input.data-entry");
// now we check to see which browser is being used
if ($.browser.mozilla) {
$(textboxes).keypress (checkForAction);
}
else {
$(textboxes).keydown (checkForAction);
}
});
function checkForAction (event) {
if (event.keyCode == 13 || 40) {
currentBoxNumber = textboxes.index(this);
if (textboxes[currentBoxNumber + 1] != null) {
nextBox = textboxes[currentBoxNumber + 1]
nextBox.focus();
nextBox.select();
event.preventDefault();
return false;
}
}
}
</script>