Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts

Friday, October 14, 2011

MVC Tips

You can use the standard ASP.NET features in your MVC views. In this case, you call the String.Format method to display the UnitPrice field in a suitable form for a monetary amount. You just pass in the Model.UnitPrice value as the argument to the method call.
<%= String.Format("{0:F2}", Model.UnitPrice) %>

String class can also be used as a formatter in thextbox:

Unit Price:
<%: Html.TextBoxFor(model => model.UnitPrice, new {Value = String.Format("{0:F2}", Model.UnitPrice)})%>