Reputation: 211
I have a label tag:
Case 1:
@Html.Label("Task:", new { @class = "labl" })
@Html.Label(@Model.insDetails.cntrctname, new { @class = "pageHeadLabel" })
Assigned value of @Model.insDetails.cntrctname ="Magic lock Test 1.25.18"
It shows as only .18
in the resulting page.
Case 2:
But If I edit the above as:
@Html.Label("Task:", new { @class = "labl" })
@Model.insDetails.cntrctname
It shows as Magic lock Test 1.25.18
on the page.
CSS class pageHeadLabel:
.pageHeadLabel {
color: #990000;
white-space: pre-wrap;
font-family: Arial, sans-serif !important;
font-size: 12px !important;
display: inline;
margin-bottom: 2px !important;
margin-left:3px;
font-weight: 200;
}
I want to correct case 1. I need output as:
Magic lock Test 1.25.18
Any solution for this?
Upvotes: 0
Views: 42
Reputation: 174
Try this:
@Html.Label(@Model.insDetails.cntrctname, @Model.insDetails.cntrctname, new { @class = "pageHeadLabel" })
In the case of Label(value, object)
, the value will be interpreted as an identifier.
By writing as Label(value, value, object)
, the value of the second argument can be output as is.
I do not know what version of the MVC you are using, but perhaps this document would be helpful.
Upvotes: 1