Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Closed Issue: MaskedEditExtender: Negative amount, followed by decimal, sets value to positive [16109]

$
0
0
Version 1.0.10618.0, but reviewed source code for most recent patch (32643) and it still appears to be present.

Scenario: When using a MaskedEditExtender with numeric format, allowing negative values, and using a format that allows decimals, setting the value to negative initially results in the value being displayed correctly. However, as the value is entered, the value is set back to positive after the decimal (or culture-specific decimal fractional character) is typed in.

Investigation: Traced faulty logic to InsertSignal in MaskedEditBehavior.js (discussion follows code snippet):

, InsertSignal : function(value)
{
var wrapper = AjaxControlToolkit.TextBoxWrapper.get_Wrapper(this.get_element());
var masktext = wrapper.get_Value();
if (value == "-" && this._LogicSymbol == "-")
{
value = "+";
}
if (value == "+")
{
value = " ";
this._LogicSymbol = "";
if (!this._InLostfocus && this._OnFocusCssClass != "")
{
this.AddCssClassMaskedEdit(this._OnFocusCssClass);
}
else if (!this._InLostfocus)
{
this.AddCssClassMaskedEdit("");
}
}
else
{
this._LogicSymbol = "-";
if (!this._InLostfocus && this._OnFocusCssNegative != "")
{
this.AddCssClassMaskedEdit(this._OnFocusCssNegative);
}
}
if (this._AcceptNegative == AjaxControlToolkit.MaskedEditShowSymbol.Left)
{
masktext = masktext.substring(0,this._LogicFirstPos-1) + value + masktext.substring(this._LogicFirstPos);
}
else if (this._AcceptNegative == AjaxControlToolkit.MaskedEditShowSymbol.Right)
{
masktext = masktext.substring(0,this._LogicLastPos+1) + value + masktext.substring(this._LogicLastPos+2);
}
wrapper.set_Value(masktext);
}

When the value is initially set to negative, the variable _LogicSymbol is set to "-". However, when the decimal is typed in, this function is called again (through the calling tree) and the logic thinks another negative sign is being entered. Therefore, it negates the negative sign and returns a positive value:

if (value == "-" && this._LogicSymbol == "-")
{
value = "+";
}

when in fact the value is simply being parsed as a result of the decimal being entered. No negative sign was actually typed; a parent function is simply iterating through the value characters to properly format the value for the associated textbox.
Comments: This issue is fixed with release April 2013 so closing this issue.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>