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);
}
}
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.
You add code to the page using the @ symbol. The @: sequence indicates that the next line should be treated as a block of content.
Html.TextArea returns a string and renders it with a razor view engine, you need to use @ at the beginning as you asked @ Html.TextArea