System.Web.UI.WebControls.TextBox.RegisterKeyHandlerClientScript C# (CSharp) Method

RegisterKeyHandlerClientScript() private method

private RegisterKeyHandlerClientScript ( ) : void
return void
		void RegisterKeyHandlerClientScript () {

			if (!Page.ClientScript.IsClientScriptBlockRegistered (typeof (TextBox), "KeyHandler")) {
				StringBuilder script=new StringBuilder();
				script.AppendLine ("function WebForm_TextBoxKeyHandler(event) {");
				script.AppendLine ("\tvar target = event.target;");
				script.AppendLine ("\tif ((target == null) || (typeof(target) == \"undefined\")) target = event.srcElement;");
				script.AppendLine ("\tif (event.keyCode == 13) {");
				script.AppendLine ("\t\tif ((typeof(target) != \"undefined\") && (target != null)) {");
				script.AppendLine ("\t\t\tif (typeof(target.onchange) != \"undefined\") {");
				script.AppendLine ("\t\t\t\ttarget.onchange();");
				script.AppendLine ("\t\t\t\tevent.cancelBubble = true;");
				script.AppendLine ("\t\t\t\tif (event.stopPropagation) event.stopPropagation();");
				script.AppendLine ("\t\t\t\treturn false;");
				script.AppendLine ("\t\t\t}");
				script.AppendLine ("\t\t}");
				script.AppendLine ("\t}");
				script.AppendLine ("\treturn true;");
				script.AppendLine ("}");
				Page.ClientScript.RegisterClientScriptBlock (typeof (TextBox), "KeyHandler", script.ToString(), true);
			}
		}
#endif