在中如何回车触发指定按钮的事件?
假设
<asp:TextBox id=TextBox runat=server Width=px></asp:TextBox>
<asp:Button id=ButtonOK runat=server BorderWidth=px BorderColor=Purple BorderStyle=Solid Text=Search Site></asp:Button>
解决方法
在aspx页面中添加
<SCRIPT LANGUAGE=javascript>
function EnterKeyClick(button)
{
if (eventkeyCode == )
{
eventkeyCode=;
eventreturnValue = false;
documentall[button]click();
}
}
</SCRIPT>
在Page_Load事件中添加
TextBoxAttributesAdd(onkeydownEnterKeyClick(ButtonOK););
关于DATAGRID数据更改时点次/行号跟不准/失去焦点/丢失e等一系列问题的解决办法首先把数据连接/dataadater等信息全放到void bindgrid中其他地方不用if(!ISPOSTBACK)在PAGELOAD的时候只用个
if (!IsPostBack)
{
BindGrid();
}
例如
private void Page_Load(object sender SystemEventArgs e)
{ if (!IsPostBack)
{BindGrid();}
}
private void DataGrid_EditCommand(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
{ DataGridEditItemIndex = eItemItemIndex;
BindGrid();
}
private void DataGrid_CancelCommand(object source SystemWebUIWebControlsDataGridCommandEventArgs e)
{ DataGridEditItemIndex = ;
BindGrid();
}
void BindGrid()
{ oleDbDataAdapterFill(dataSet);
DataGridDataBind();
}