Wednesday, October 2, 2013

Using Razor syntax with Javascript

Following approach was done to have the razor syntax in Javascript. Wrapping the javascript <text> with does the job!

@if(Model!=null){
<text>"<span style="color: #76768d; font-size: 14px; font-weight: bold;">@Model.title</span>" +</text>
}


Although the code above looks like Razor syntax placed in HTML, this has been used in Javascript and works perfect!

No comments: