Format strings are used to format data before presentation to the end user. There are standard numeric and date/time format strings. In addition, custom date/time format strings can be created. The formatting is performed in the client web browser by default.
Microsoft.NET offers rich data formatting capabilities. Developers may request formatting of field values on the server to take advantage of everything it has to offer.
For example, the Unit Price field in the Order Details controller uses the standard currency format string of “c”. An application with en-US culture will format the number as a currency with a dollar sign on the left, period as a decimal separator, and parenthesis's to indicate negative values. The $0.00 indicates a zero value.
Server-side formatting offers additional field value formatting options.
Start the Project Designer. In the Project Explorer, switch to the Controllers tab and double-click on Order Details / Fields / UnitPrice field node.
Change the following properties:
Property | New Value |
Data Format String | 000,000.00;(000.00);Zero Value |
Format On Client | False |
The data format string is a custom numeric format string. Positive, negative, and zero value strings are separated by a semicolon.
Press OK to save the field. On the toolbar, click on the Browse button to generate the web application.
Navigate to the Order Details page. The values in Unit Price field will be formatted according to the custom numerical format string. All eight digits will be displayed. Zero values will be represented with the text “Zero Value”.
Notice that when the row is in edit mode, the values of fields formatted on the server will be displayed in raw form.