Reputation: 938
I have something like that in my ASP.NET MVC View page.
<li>Status: <span id="serviceStatus">formatServiceAvaibility(@service.Avaiable);</span></li>
service is stronly typed object. And function:
function formatServiceAvaibility(serviceStatus) {
if (serviceStatus == true)
return 'ON';
return 'OFF';
}
Why this doesn't work while loading page? Result is: Status: formatServiceAvaibility(True);
How to make that?
Upvotes: 0
Views: 57
Reputation: 9490
That may be because c# formats bool with a capital letter. Try to change the code to
formatServiceAvaibility(@(service.Avaiable ? "true" : "false"));
or
formatServiceAvaibility(@(service.Avaiable.ToString().ToLower()));
Upvotes: 2