Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Formatting Field Values - ASP.NET MVC

Compare Page Revisions



« Older Revision - Back to Page History - Newer Revision »


Page Revision: Tue, Dec 07, 2010, 4:17 PM


Overview

By default, the Html.TextBoxFor method applies no formatting to field values. This article describes how to easily format the data and still have MVC pickup the changes for the view model.

Solution

The following code demonstrates how to format field values within an ASPX page on a site that's using MVC.

<%: Html.TextBox("Account.Balance", 
        String.Format("{0:F2}", Model.Account.Balance), 
        new {   id="Account_Balance", 
                style="width:6em;"} )
        %>

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.