-1
Apparently HTML and markup helpers can perform the same functions, like this example I found in microsoft documentation:
HTML auxiliaries
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizo" }))
{
@Html.AntiForgeryToken()
<h4>Create new account.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBorFor(m => m.Email, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Register" />
</div>
</div>
}
Marking aids
<form asp-controller="Account" asp-action="Register" method="post" class="form-horizo">
<h4>Create new account.</h4>
<hr />
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
<label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Register" />
</div>
</div>
</form>
It really seems to me that they do the same things, only with different syntaxes, so I came up with the following doubts:
- There is some difference in what one HTML helper and one markup helper can do that the other cannot?
- Is there any recommendation, or good practice on which one I should use?
- In terms of performance, some of them stand out, or are equivalent?
Always put code as text formatting with
Ctrl+K
or by clicking the button{}
of the editor.– Isac
@Isac Actually the intention was just to add a small part of the example in the Microsoft documentation (which uses these images), I will write the code then.
– Vinícius Lima
Can you please tell me the reason for the negatives, so I can edit the question to fit? : D
– Vinícius Lima