Set disable attribute based on a condition for Html.TextBoxFor

The valid way is: disabled=”disabled” Browsers also might accept disabled=”” but I would recommend you the first approach. Now this being said I would recommend you writing a custom HTML helper in order to encapsulate this disabling functionality into a reusable piece of code: using System; using System.Linq.Expressions; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; using … Read more

How to change the display name for LabelFor in razor in mvc3?

You could decorate your view model property with the [DisplayName] attribute and specify the text to be used: [DisplayName(“foo bar”)] public string SomekingStatus { get; set; } Or use another overload of the LabelFor helper which allows you to specify the text: @Html.LabelFor(model => model.SomekingStatus, “foo bar”) And, no, you cannot specify a class name … Read more

How do you tell Resharper that a method parameter is a string containing a CSS class?

Use [ValueProvider] From the Code Annotations currently supported by Resharper 10, the best candidate would to use this attribute. From the above link: ValueProviderAttribute For a parameter that is expected to be one of the limited set of values. Specify fields of which type should be used as values for this parameter. Unfortunately, I’ve not … Read more

Html helper for

HTML Upload File ASP MVC 3. Model: (Note that FileExtensionsAttribute is available in MvcFutures. It will validate file extensions client side and server side.) public class ViewModel { [Required, Microsoft.Web.Mvc.FileExtensions(Extensions = “csv”, ErrorMessage = “Specify a CSV file. (Comma-separated values)”)] public HttpPostedFileBase File { get; set; } } HTML View: @using (Html.BeginForm(“Action”, “Controller”, FormMethod.Post, new … Read more