Why does HTML.TextArea require @ before this?
Below doesn't seem to work unless @ is in front of @Html. Why is this?
@{
if (DescriptionIsFieldReadOnly) {
Html.TextArea("description-edit", Model.Requisition.ReqHdr.Description, new { @Readonly = "readonly" });
}
else {
Html.TextArea("description-edit", Model.Requisition.ReqHdr.Description);
}
}
+3
source to share
2 answers
Html.TextArea(...)
returns IHtmlString
with the HTML code you want.
If you call it a normal function, you are not actually doing anything with that return value, so nothing happens.
Usage @
turns it into a Razor expression that outputs its value to the page.
By the way, this is not a statement, so it shouldn't have a semicolon.
+3
source to share