separate numbers by comma with asp.net mvc

[DisplayFormat(DataFormatString = "{0:n}")]
public virtual GrossFee? Fee { get; set; }

hope this can help you


Instead of the Html.TextBoxFor you can use the Html.EditorFor and have the view respect the data annotations like this:

Model:

(I don't know what GrossFee? is but lets assume its a decimal)

[DisplayFormat(DataFormatString = "{0:0,0}")]
public virtual Decimal? Fee { get; set; }

View:

Html.EditorFor(model => model.GrossFee)

You may also need to tweak the HtmlEncode and ApplyFormatInEditMode to suit your particular application.

Anything that converts the textbox contents into comma grouped numbers as soon as entered (I.e. before the post back) would need to be javascript based.