Input mask on an Ajax combobox

287 Views Asked by At

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?

1

There are 1 best solutions below

0
On

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;
   }
}