asp.net mvc - MVC how to check for NULL in model.property -


in razor-view, how can check existence of property in model?

if (model._myprop != null)  <--- error .runtimebinder.runtimebinderexception if model not contain _myprop     {       ...do     } 

you not want check 1 of model's properties has value null want check type having property or not , ofcourse solution not work way @satpal's wont work too.

use stronly typed views , separate different properties interfaces , use them partial views.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -