问题
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