Check whether a char is null or empty in razor view

大城市里の小女人 提交于 2020-05-16 06:00:48

问题


It seems to be a fundamental question, but I could not find the exact answer.

I am passing a null or empty char value ('\0' in c#) from Model to View, and in View I need to check whether the char is equal to null or empty.

I have tried the following:

if ("@Model.CharValue" != "\0") {...}
if ("@Model.CharValue" != '\0') {...}
if ("@Model.CharValue" != ' ') {...}

None of them gave me the proper check. and using

alert("@Model.CharValue");

The pop up gave me this character, which I have no idea what it is.

How can I check whether a char is null or empty in Javascript when it is passed from Model to razor View?

来源:https://stackoverflow.com/questions/43662939/check-whether-a-char-is-null-or-empty-in-razor-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!