Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ASP MVC without Annotations

Tags:

asp.net-mvc

I'm just learning how to do ASP MVC. All of the tutorials I see use a combination of Html.LabelFor and the DisplayAttribute. Personally, I'm not a big fan of adding these kinds of annotations to my model objects and I'd like to know if there is an accepted alternative. I thought this might be a place for something like Knockout or Backbone, but I'm so new to this stuff that I'm having difficulty wrapping my brain around the different pieces.

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

Thanks in advance

like image 343
basilard99 Avatar asked Jul 27 '26 01:07

basilard99


1 Answers

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>

It is true for all asp.net mvc html helpers

like image 174
mola10 Avatar answered Jul 30 '26 10:07

mola10