簡體   English   中英

如何使用箭頭鍵在ASP.NET Gridview中上下移動

[英]How to Move up and down in ASP.NET Gridview Using Arrow Keys

我在網格視圖控件ItemTemplate中有一個網格視圖控件,現在我想要的是文本框,按向下箭頭鍵,第一行的第一個文本框中的光標將轉到第二行的第一個文本框中

這是我想做的網格視圖

使用此URL,它與代碼一起使用。 使用箭頭鍵瀏覽文本輸入字段並返回

    <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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM