<script language="javascript"> function document.onkeydown() { var e = event.srcElement; //do not use the last two conditions if you don't care if it is a textbox or not if (event.keyCode == 13 && e.tagName == "INPUT" && e.type == "text") event.keyCode = 9; } </script>
to 无语: 能说的具体一点吗?to 吉祥: 您这是取回车键,我问在取得回车键后怎样进行查询,谢谢!
能说的具体一点吗?
分不够可以加
1。自定义一个ITEMPLATE,叫TEXTBOXTEMPLATE,里面就是TEXTBOX,然后把TEXTCHANGEED事件暴露出来,并且能设置AUTOPASTBACK。
2 自定义模板列,把TEXTBOXTEMPLATE加进来,接受在TEXTBOXTEMPLATE暴露得事件,也就是
事件传递。
3。在DATAGRID里用这个自定义模板列,并登记自定义模板列里得传递事件,这样就可以在.ASPX里捕获TEXTCHANGED事件了,
剩下得自己去想吧
查询并保存值(在Session或者ViewState中)
重新绑定数据
function document.onkeydown()
{
var e = event.srcElement;
//do not use the last two conditions if you don't care if it is a textbox or not
if (event.keyCode == 13 && e.tagName == "INPUT" && e.type == "text")
event.keyCode = 9;
}
</script>
能说的具体一点吗?to 吉祥:
您这是取回车键,我问在取得回车键后怎样进行查询,谢谢!
1、模板列代码:
<asp:TemplateColumn>
<ItemTemplate>
<asp:TextBox ID="aaa" Runat=server onkeydown="javascript:refresh();"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
2、客户端函数:
<script language="javascript">
function refresh()
{
if (event.keyCode == 13)//如果输入回车
{
window.location = window.location + "?Mode=refresh"
}
}
</script>3、服务器端处理
private void Page_Load(object sender, System.EventArgs e)
{
if (Request.QueryString["mode"] != null && Request.QueryString["mode"] .ToString() == "refresh")
{
this.RefreshData();
}
}RefreshData();就是你刷新数据的函数。