asp.net 回车事件
我现在想做一个功能
就是单机button按钮后再判断是否按了回车键
这个要怎么做
急求!!!!!!!!
------解决方案--------------------e.keycode
------解决方案--------------------JS,用前端很容易!!!!!
------解决方案--------------------//在PageLoad()事件中在调用
SetDefEnterControl(ImgBtnSearch);
/// <summary>
/// 定义一个鼠标回车触发按钮的事件的方法
/// </summary>
/// <param name="Ctrl">控件名称</param>
public static void SetDefEnterControl(System.Web.UI.Control Ctrl)
{
Page mPage = Ctrl.Page;
string mScript; mScript = @"<script language=""javascript""> ";
mScript += "function document.onkeydown() {";
mScript += "var e = event.srcElement; ";
mScript += "var k = event.keyCode; ";
mScript += @"if (k == 13 && e.type != ""textarea"") { ";
mScript += "document.all." + Ctrl.ClientID + ".click(); ";
mScript += "event.cancelBubble = true; ";
mScript += "event.returnValue = false; ";
mScript += "} }</script>";
if (mPage.ClientScript.IsClientScriptBlockRegistered(mPage.GetType(), "SetEnterControl") == false)
mPage.ClientScript.RegisterClientScriptBlock(mPage.GetType(), "SetEnterControl", mScript);
}
------解决方案--------------------