I'm outputting a fews strings using Html.Label(strings).
When I pass it a value with a period in it, it outputs nothing but spaces
Html.Label(company)
e.g <%: Html.Label("Bill Co.")%>
Company is a dynamic value, it will work if the value is "Bill Co" but not if it is "Bill Co.", the only difference is that period.
I should be able to pass any string to it as per HhtmlHelper.Label via msdn
public IHtmlString Label(
string labelText
)
Any ideas?
You can also use
<%= Html.Label("","Bill Co.")%>
When using Html.label()
, the parameter needs to be an expression that identifies the property to display and the for attribute.
When using Html.label(), the parameter needs to be an expression that identifies the property to display. I don't think there is a property in your model named Bill Co.
.
You need to specify it like this:
<%: Html.Label("Name")%>
or this:
<%: Html.Label(model => model.Name)%>
If you just need to output a constant value as a label use the <label>
tag:
<label>Bill Co.</label>
I used ToHtmlString() and that solved the issue.
Thanks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With