Is there a way to render text into a span
element when an ASP MVC 3 view loads? For instance
if I have <span id="territoryName"></span>
how would I load the data from Model.Region
into the span
element as text?
If you are using Razor you can use the following.
<span id="territoryName">@Model.Region</span>
Note: the value will be HTML-encoded.
Without HTML-encoding:
<span id="territoryName">@Html.Raw(Model.Region)</span>
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