Percentage Formatting issue

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
cheemingyong
User
Posts: 37

Percentage Formatting issue

Post 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 ?


motfs
User
Posts: 258

Post 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.


cheemingyong
User
Posts: 37

Post 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%


Webmaster
User
Posts: 9427

Post 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";


Post Reply