For some reason this logic is working for every node i want it to work on apart from 2. 'alternateColourImage' is an 'upload' property, if it there is no image uploaded to the node i dont want the browser to write anything. but for some reason its writing this for two of my nodes 'col:end' so obviuosly there is no value assigned to the property but its still writing this text out! any ideas?
I think it's to do with the logic of your condition. If the value is not null OR not String.Empty ... but if it was null, then that would make the " != String.Empty" to be true... right? Which would display the condition.
I'd suggest that you assign the GetProperty() to a variable, saves recalling the method (not sure if it gets cached, or hits the database each time?) ... to something like this:
With the condition, you'll need to check that the Property itself is not null, then if the Value is not null, then finally that the Value (as a String) is not null/empty. Seems a bit long winded, but its better to be safe, right?
upload property not returning null
if ((color.GetProperty("alternateColourImage").Value != null) || (color.GetProperty("alternateColourImage").Value != String.Empty))
{
Response.Write("col:" + color.GetProperty("alternateColourImage").Value + "end");
}
For some reason this logic is working for every node i want it to work on apart from 2. 'alternateColourImage' is an 'upload' property, if it there is no image uploaded to the node i dont want the browser to write anything. but for some reason its writing this for two of my nodes 'col:end' so obviuosly there is no value assigned to the property but its still writing this text out! any ideas?
Hi Phil,
I think it's to do with the logic of your condition. If the value is not null OR not String.Empty ... but if it was null, then that would make the " != String.Empty" to be true... right? Which would display the condition.
I'd suggest that you assign the GetProperty() to a variable, saves recalling the method (not sure if it gets cached, or hits the database each time?) ... to something like this:
With the condition, you'll need to check that the Property itself is not null, then if the Value is not null, then finally that the Value (as a String) is not null/empty. Seems a bit long winded, but its better to be safe, right?
Cheers, Lee.
is working on a reply...