Tuesday, April 28, 2015

Backspace or Delete key In TextBox with Masked Edit Extender in ASP.NET not working

1) Create MaskedEditFix.js File

(function(){try{var n=Sys.Extended.UI.MaskedEditBehavior.prototype,t=n._ExecuteNav;n._ExecuteNav=function(n){var i=n.type;i=="keydown"&&(n.type="keypress"),t.apply(this,arguments),n.type=i}}catch(i){return}})()

2) Add to .cs file

 protected void Page_Init(object sender, EventArgs e)
        {
            if (!ClientScript.IsStartupScriptRegistered(GetType(), "MaskedEditFix"))
            {
                ClientScript.RegisterStartupScript(GetType(), "MaskedEditFix", String.Format("<script type='text/javascript' src='{0}'></script>", Page.ResolveUrl("../Scripts/MaskedEditFix.js")));
            }
        }

3) Then check

6 comments:

  1. Thank you, you solved my problem.

    I love you. You are a GOD.

    I hate legacy projects

    ReplyDelete
  2. Thank you so much.
    its works for me.

    ReplyDelete
  3. Thank you so much.
    its works for me.

    ReplyDelete
  4. it does not work for me..could you provide the contect of MaskedEditFix.js? any steps i missed out?

    ReplyDelete