I'm using ASP.Net 4.0 to create a web project, and I have two Ajax ComboBoxes on one of my pages. The users have requested input masks on the two ComboBoxes. I can't use the Ajax MaskedEditExtender, since it won't work with a ComboBox. Has anyone ever implemented input masks on an Ajax ComboBox?
-
If you are okay with jQuery this is what I use for all my masked inputs (http://digitalbush.com/projects/masked-input-plugin/). It's a great plugin that is easy to use. I don't see why this would not work on a combo box, but 'I have not tested to be sure'. – Joseph Astrahan Dec 30 '13 at 20:53
-
Thank you Joseph. I'll give this a try. I took a look at digitalbrush's website and I understand the mask syntax, but how do you reference it within a .Net control? For example if I wanted my mask to be called #imei and I have a control called cbIMEI (my Ajax ComboBox), how do I connect the jQuery definition of the #imei mask with the cbIMEI control? – Melanie Dec 30 '13 at 21:13
-
Hang on, I think I'm misunderstanding something on their website. If I need help, I'll let you know. Thanks! – Melanie Dec 30 '13 at 21:17
1 Answers
DevExpress editors allow you to use masks during editing. Masks are useful when a string entered by an end-user should match a specific format. For instance, you may require a text editor to only accept date/time values in a 24-hour format, only accept numeric values, or only accept numbers that are automatically inserted into the placeholders of a telephone number.
Masked input is supported by the following editor types:
Text box editors (ASPxTextBox and ASPxButtonEdit). Text box mask settings can be accessed via the MaskSettings property. The editor’s mask can be specified via the MaskSettings.Mask property. Date editors (ASPxDateEdit). To enable masked input within a date editor, the UseMaskBehavior property should be set to true. The mask can be defined via the EditFormatString property if the EditFormat property is set to 'Custom'. In this demo, see how masked input behavior is implemented by entering data into the various types of editors.
learn more here
using System;
using System.Web.UI;
public partial class Features_MaskedInput : Page {
protected void Page_Load(object sender, EventArgs e) {
txtZip.MaskSettings.PromptChar = cmbPromtChar.SelectedItem.Value.ToString()[0];
dateEdit.EditFormatString = cmbDateType.SelectedItem.Value.ToString();
dateEdit.Value = DateTime.Now;
}
}

- 21
- 4