Hi I am using C# razor with umbraco cms. I am trying to check if a variable is null or empty but it always returns an error. Here is the code
@if(String.IsNullOrEmpty(@Model.originalPageLink) == false)
{
<div>Read the original page from <a href="@Model.originalPageLink">@Model.originalPageName</a></div>
}
When loading the page the razor script errors out. There is no particular error information that is useful. The part of the code thats giving me problems is this:
@if(String.IsNullOrEmpty(Model.originalPageLink) == false)
I have tried this code here:
@if(Model.originalPageLink != null)
This code does not error out but returns a non null value when the string is really null.
Any ideas on this?
OK..I have figured it out.. Here is the solution
I have to put ToString() on the dynamic variable. Now it works correctly now.