Page 1 of 1
Percentage Formatting issue
Posted: Wed Aug 16, 2017 3:24 pm
by cheemingyong
hi anyone knows a better way to format percentages in asp.net maker ?
right now 0.0X means X% by using the format option under View Tag under Fields Tab for a table
But normally people enter the actual percentage for example 2 which should represent 2 percent
instead of entering 0.02 for 2%
is there a proper fix for this issue ?
also is there a cleaner way of putting a suffix for an input entered field example cm, inches or foot
instead of going down to the code level or using jquery ?
Re: Percentage Formatting issue
Posted: Thu Aug 17, 2017 11:51 am
by motfs
format percentages
Use the Row_Inserting server event (or Row_Updating server event) to handle the value, e.g.
rsnew["<field>"] = ew_ConvertToDouble(rsnew["<field>"]) / 100;
putting a suffix for an input entered field example cm
You may add additional field to input the unit and use Custom Template to rearrange the layout for the Add form or Edit Form. Then, you can perform a conversion for the input if the unit is different from the default unit in the Row_Inserting server event (or Row_Updating server event). Please read Custom Template in help file for more detail.
Re: Percentage Formatting issue
Posted: Fri Aug 18, 2017 11:33 am
by cheemingyong
hi thank you for your reply. but this doesn't solve the problem because after you save it with a /100
its going to come back after saving as 0.02 which means 0.02 percent to the user when it should read 2%
Re: Percentage Formatting issue
Posted: Fri Aug 18, 2017 11:46 am
by Webmaster
motfs wrote:
format percentages
Use the Row_Inserting server event (or Row_Updating server event) to handle the value, e.g.
rsnew["<field>"] = ew_ConvertToDouble(rsnew["<field>"]) / 100;
Better check the value, e.g. if > 1, assume percentage and divide it by 100. If < 1, assume decimal number and don't change.
putting a suffix for an input entered field example cm
Just set field object's CustomMsg property, e.g. in Page_Load server event,
YourField.CustomMsg = "cm";