Internet Explorer assigns the first html input field with type submit (an Asp.Net button for example) to receive the Enter keypress on a webpage when in a field.
Put this into your declerations section of your page:
Code:
protected System.Web.UI.HtmlControls.HtmlForm Form1;
or for VB:
Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
Put this into your Page_Load handler:
c#
Code:
if (!(Page.IsPostBack))
{
Page.RegisterStartupScript("blockEnter",
"<script type=\"text/javascript\">function inspectEvent(evt){if (evt.keyCode == 13)return false;}</script>");
Form1.Attributes.Add("onkeypress","return inspectEvent(event)");
}
Vb
VB Code:
If Not Page.IsPostBack
Page.RegisterStartupScript("blockEnter", _
"<script type=""text/javascript"">function inspectEvent(evt){if (evt.keyCode == 13)return false;}</script>")
Form1.Attributes.Add("onkeypress","return inspectEvent(event)")
End If