MaskedEditExtender问题 [英] MaskedEditExtender problem
问题描述
我在页面上有一个MaskedEditExtender,代码如下
I have a MaskedEditExtender on a page, code below
< ajaxToolkit:MaskedEditExtender ID =" MaskedEditExtenderAmount" runat =" server"
RightToLeft"
AcceptNegative =" None"
DisplayMoney =" None"
ClearMaskOnLostFocus =" true"
ErrorTooltipEnabled =" True" />
< ajaxToolkit:MaskedEditValidator ID =" MaskedEditValidatorAmount" runat =" server"
ControlExtender =" MaskedEditExtenderAmount"
ControlToValidate =" TextBoxAmount"
IsValidEmpty =" False"
MaximumValue =" 1"
EmptyValueMessage =" Number是必需的"
InvalidValueMessage ="数字无效"
MaximumValueMessage =" Number&g吨; 1"
MinimumValueMessage =" Number< 0"
MinimumValue =" 0"
Display =" Dynamic"
TooltipMessage ="输入一个从0.00到1.00的数字"
EmptyValueBlurredText =" *"
InvalidValueBlurredMessage =" *"
MaximumValueBlurredMessage =" *"
MinimumValueBlurredText =" *"
ValidationGroup =" AssetBreakdown" />
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtenderAmount" runat="server"
TargetControlID="TextBoxAmount"
Mask="9.99"
MessageValidatorTip="true"
MaskType="Number"
InputDirection="RightToLeft"
AcceptNegative="None"
DisplayMoney="None"
ClearMaskOnLostFocus="true"
ErrorTooltipEnabled="True" />
<ajaxToolkit:MaskedEditValidator ID="MaskedEditValidatorAmount" runat="server"
ControlExtender="MaskedEditExtenderAmount"
ControlToValidate="TextBoxAmount"
IsValidEmpty="False"
MaximumValue="1"
EmptyValueMessage="Number is required"
InvalidValueMessage="Number is invalid"
MaximumValueMessage="Number > 1"
MinimumValueMessage="Number < 0"
MinimumValue="0"
Display="Dynamic"
TooltipMessage="Input a number from 0.00 to 1.00"
EmptyValueBlurredText="*"
InvalidValueBlurredMessage="*"
MaximumValueBlurredMessage="*"
MinimumValueBlurredText="*"
ValidationGroup="AssetBreakdown" />
蒙版工作正常。我将值提交给数据库并正确保存。作为一个例子,我保存值0.2
The mask works ok. I commit values to the database and they save correctly. As an example i save the value 0.2
当我将这些数据重新加载到文本框中时,它显示为0.02!
When I subsequenly reload this data into the text box, its displaying as 0.02 !
我检查了值从数据库返回它是0.2,所以掩码以某种方式重新格式化为0.02
Ive checked the values being returned from the database and it is 0.2, so the mask is somehow reformatting it as 0.02
从数据库返回的值是类型double并显示它我使用这行代码
The value returned from the database is of type double and to display it I use this line of code
TextBoxAmount.Text = inValue.ToString();
TextBoxAmount.Text = inValue.ToString();
推荐答案
试试这个
TextBoxAmount.Text = inValue.ToString(" F2");
而不是TextBoxAmount.Text = inValue.ToString();
try this
TextBoxAmount.Text = inValue.ToString("F2");
instead of
TextBoxAmount.Text = inValue.ToString();
这篇关于MaskedEditExtender问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!