Using ASP MVC without annotations

I am just learning how to do ASP MVC. All the tutorials I see use a combination of Html.LabelFor and DisplayAttribute. Personally, I'm not a big fan of adding these annotations to my model objects, and I would like to know if there is an acceptable alternative. I thought this might be a place for something like Knockout or Backbone, but I'm so new to this stuff that it's hard for me to hide my brain around different parts.

I know this has probably already been asked and answered; I can't even figure out how to do this :(

Thank you in advance

+3


source to share


1 answer


you can skip data annotations

You can write

<label for='@(var1)'>@Name</label>

      

or



<label for='name1'>Text</label>

      

or



Html.Label("ControlName", "Name")

      

or



Html.LabelFor  with data anot.

      

any of this will be correct

also using helpers with lamda expressions (Html.LabelFor) is much slower than Html.Label or simple html code <label for='@(var1)'>@Name</label>

This is true for all asp.net mvc html helpers

+1


source







All Articles