how would I do the equivalent of this embedded in JavaScript on an MVC2 aspx page:
if (('<%= Model.SomeFunctionEnabled %>' == 'True')
and also a whole function code block on a Razor view page (cshtml) in MVC3?
Something like :
@{
foreach(var d in Model.Employees)
{
....
}
}
Which works fine when embedded in the HTML part of the view page. Thanks
Embedded C is a set of language extensions for the C programming language by the C Standards Committee to address commonality issues that exist between C extensions for different embedded systems.
In embedded system programming C code is preferred over other language. Due to the following reasons: Easy to understand. High Reliability.
Why testing on the client side when you could do this on the server side and include the javascript to act accordingly if the test succeeds:
<script type="text/javascript">
@if (Model.SomeFunctionEnabled) {
<text>
// Put your javascript code here
alert('the function is enabled');
</text>
}
</script>
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