I want to check that a Model value is NULL or NOT NULL in my view model in JavaScript, using mvc4.
How would I check this?
How do I get the values from my Model in JavaScript in the View model?
There may be two way
first
@{
string property = "";
property = Model.Property == null ? "null value" : "value";
// OR another comparison strategy
...
}
<script type="javascript">
var property = @(property);
</script>
second
<script type="javascript">
var property = @(Model.Property == null ? "null value" : "value");
</script>