Enter键代替Tab键的功能;为按钮添加消息框confirm(),alert();动态生成表格


   1  Enter键代替Tab键的功能;
   2  为按钮添加消息框confirm();
   3  alert();动态生成表格;
========================================

1 使用Enter键代替Tab键的功能
 <script language="javascript">
  function keyDown()
  {
    var keycode=event.keyCode;
    var keyChar=String.fromCharCode(keycode);
    if(keycode==13)
     event.keycode=9;
  };
   document.onkeydown=keyDown;
 </script>

2 //为按钮添加消息框
   confirm(),alert()

3 //动态生成表格
  private void Button1_Click(object sender, System.EventArgs e)
  {     
   int numrows = int.Parse(DropDown1.SelectedItem.Value);
   int numcells = int.Parse(DropDown2.SelectedItem.Value);          
   for (int j=0; j<numrows; j++)
   {           
    TableRow newRow = new TableRow();              
    for (int i=0; i<numcells; i++)
    {
     TableCell newCell = new TableCell();
     newCell.Controls.Add(new LiteralControl("行 " + j.ToString() + ":"));
     TextBox newControl = new TextBox();
     newControl.Text = "单元格 " + i.ToString();
     newCell.Controls.Add(newControl);
     newRow.Cells.Add(newCell);
    }              
    Table1.Rows.Add(newRow);
   }
  }

原文地址:https://www.cnblogs.com/csj007523/p/1155133.html