Answered by:
Getting familiar with razor code!

Question
-
User1421620300 posted
The following is a snippet of code from my view page. I am new to programming the front end so this was just to see if i could get some balance in this area of programming. The problem is that my project is original code from CRUD operations in MVC. But only thing is i wanted to know how the new statement is being used inside of the HTML as shown in bold text! Can someone explain?
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Coach</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>Sunday, November 25, 2018 7:43 PM
Answers
-
User475983607 posted
The following is a snippet of code from my view page. I am new to programming the front end so this was just to see if i could get some balance in this area of programming. The problem is that my project is original code from CRUD operations in MVC. But only thing is i wanted to know how the new statement is being used inside of the HTML as shown in bold text! Can someone explain?
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Coach</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>In this example "new" is building element attributes. In this case the CSS "class" attribute.
The openly published HTML help docs explain the method overloads.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, November 25, 2018 7:57 PM
All replies
-
User475983607 posted
The following is a snippet of code from my view page. I am new to programming the front end so this was just to see if i could get some balance in this area of programming. The problem is that my project is original code from CRUD operations in MVC. But only thing is i wanted to know how the new statement is being used inside of the HTML as shown in bold text! Can someone explain?
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Coach</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
</div>
</div>In this example "new" is building element attributes. In this case the CSS "class" attribute.
The openly published HTML help docs explain the method overloads.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, November 25, 2018 7:57 PM -
User-552477072 posted
Hi Markus33,
To know in depth about new element in HTML you can follow link below:
https://www.w3schools.com/html/html5_new_elements.asp
w3schools always better choice for practice and learning. Thanks.
Monday, November 26, 2018 3:15 AM