初学C#+ASP.NET+Oracle备忘录

在asp.net中,如何回车触发指定按钮的事件?

假设:


<asp:TextBox id="TextBox1" runat="server" Width="240px"></asp:TextBox>

<asp:Button id="ButtonOK" runat="server" BorderWidth="1px" BorderColor="Purple" BorderStyle="Solid" Text="Search Site"></asp:Button> 

 解决方法:

在.aspx页面中添加:

<SCRIPT LANGUAGE="javascript">

function EnterKeyClick(button)

{   

if (event.keyCode == 13)

{        

event.keyCode=9;

event.returnValue = false;

document.all[button].click();

}

}

</SCRIPT>  

 在Page_Load事件中添加:

TextBox1.Attributes.Add("onkeydown","EnterKeyClick('ButtonOK');");  

 关于DATAGRID数据更改时点2次/行号跟不准/失去焦点/丢失e等一系列问题的解决办法:首先把数据连接/dataadater等信息全放到void bindgrid中,其他地方不用if(!ISPOSTBACK),在PAGELOAD的时候只用个

   if (!IsPostBack)
   {
       BindGrid();
   } 

--------------------------------------------------------------

例如: 

 private void Page_Load(object sender, System.EventArgs e)
  { if (!IsPostBack)
   {BindGrid();}
  }
  private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  { DataGrid1.EditItemIndex = e.Item.ItemIndex;
   BindGrid();
  }
  private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  { DataGrid1.EditItemIndex = -1;
   BindGrid();
  }
  void BindGrid()
  { oleDbDataAdapter1.Fill(dataSet11);
   DataGrid1.DataBind();
  }

转载于:https://www.cnblogs.com/nianshi/archive/2007/06/25/794408.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值