Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is there a way to automatically treat null as '' ?
Message
 
 
To
05/10/2012 18:58:21
General information
Forum:
ASP.NET
Category:
MVC
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01554434
Message ID:
01555106
Views:
48
>Try the DisplayFormat attribute with NullDisplayText set to an empty string: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayformatattribute.aspx

Rob,

Google Chrome and FireFox display empty string when the value is null while IE 9 displays null and also for some reason doesn't display images for the buttons.

I found this answer http://stackoverflow.com/questions/476436/null-coalescing-operator-for-javascript but it's not exactly clear to me.

If I have a value =null and I want to replace it with an empy string, how will it behave? According to that answer, both null and empty string are the same in JavaScript.

I have this code
$('#Contact1').val($('.trSelected td:eq(3)').text());
and I am wondering if I should try
$('#Contact1').val(($('.trSelected td:eq(3)').text()||''));
BTW, this didn't work, since the value is already a string 'null' not the null. May be instead of text in the above I need to use val()
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform