views:

424

answers:

2

I'm creating a simple composite control that has AJAX functionality. When trying to implement a MaskedEditValidator, the DisplayMoney property doesn't work. The MaskedEdit renders, without the dollar sign attached. Any ideas? Here's my code:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    priceTextbox.ID = this.ID + "_price";
    quantityTextbox.ID = this.ID + "_quantity";
    timeTextbox.ID = this.ID + "_time";
    submitButton.ID = this.ID + "_submit";
    submitButton.Text = "Submit";
    priceMask.TargetControlID = priceTextbox.ClientID.ToString();
    priceMask.ID = priceMask.TargetControlID.ToString() + "_extender";
    priceMask.BehaviorID = "priceMaskExtender";
    priceMask.Mask = "99.99";
    priceMask.DisplayMoney = MaskedEditShowSymbol.Left;

}
+1  A: 

Try adding the following line:

priceMask.MaskType = MaskedEditType.Number;

Optionally, set ClearMaskOnLostFocus to false if that is the behavior you want (it keeps the dollar sign even when not focused).

The DisplayMoney property setter only sets the property if MaskType is equal to MaskedEditType.Number.

set
{
   if (MaskType == MaskedEditType.Number)
   {
     SetPropertyValue("DisplayMoney", value);
   }
}
colithium
+1  A: 

The DisplayMoney property setter only sets the property if MaskType is equal to MaskedEditType.Number.

set
{
   if (MaskType == MaskedEditType.Number)
   {
     SetPropertyValue("DisplayMoney", value);
   }
}

So you need to set:

priceMask.MaskType = MaskedEditType.Number;
cgreeno