asp.netmaskededitextender

How to get the EmptyMask of a MaskedEdit extender by using C#?


According to a thread in forums.asp.net, the Empty Mask is the displayed mask on the input text box, e.g. "_ _ _ _ / _ _ / _ _". On the server side code, the MaskedEdit.Mask property keeps only the configuration mask string which is not replaced by any prompt characters, i.e. "9999/99/99".

My question is, is there a way we can retrieve the Empty Mask directly without extra coding? or the simplest code to get it done.

Thanks

William


Solution

  • The empty mask is computed on the client side by the MaskedEdit behavior, so that information does not actually exist on the server side. You can obtain it from Javascript code through the _EmptyMask property of the behavior object (but that property is "private", so YMMV depending on the toolkit's version).

    If you absolutely need that information on the server side, you can look at the AJAX Control Toolkit source code, specifically the _createMask() method in MaskedEditBehavior.js, and reimplement its logic in C#.