I am working on Project in which there are more than 500 .aspx pages(Popups uses ShowModelDialog) I want Suppress/Disable Enter Key for each Page
I want to Add Below Code for Every page (all Popup )or for every Request made by User. Unfortunately There is no master page in the project
<script type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
</script>
void Application_BeginRequest(object sender, EventArgs e)
{
// Code that runs on application shutdown
System.Web.UI.Page mypage = (System.Web.UI.Page)HttpContext.Current.Handler;
if (mypage != null)
{
mypage.ClientScript.RegisterClientScriptBlock(GetType(), "MyScriptKey", "alert('hi')", true);
}
}
I try to add this script in Global.asax
in Application_BeginRequest
but no luck
I used
Application_PreRequestHandlerExecute
event inGlobal.asax
file and it worked.