Render span element with text from Model

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?

Answers


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>

Need Your Help

How can I overlay a frame with news on top of a already established website first page?

php html

I'm having problems on finding a easy solution to present a news frame on top of the already established website first page.

Create PHP P2P game client tracker

php c++ networking p2p

At the moment I'm looking into creating a networked game using P2P. The game is not that high paced and I don't have access to a dedicated server, so P2P seems like a good choice to me. I do have a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.