Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello Everyone,
I am trying to test to see if a user has left a certain field null. If they have then i will render one of the other fields as below:
@if(@Umbraco.Field("Field1"){
do this
}
else{
I cant test using @RenderLinkIfNotEmpty. And when i look at the cheat sheet is shows .IsNull(property Alias).
What is the best way for me to achieve this?
Kind regards.
Hi James,
I assume that you are doing this directly in the template and not a in partial view maco.
Try this:
@if (string.IsNullOrWhiteSpace(CurrentPage.Field1) == false){ do this}else{ do this}
If my assumption is wrong, do not hesitate to write again
Hope this helps,
/Dennis
How about
@if (CurrentPage.HasValue("Field1")){ <p>it's not null or empty</p> }else{ <p>it's null or empty</p> }
I'm getting true even value is null. Umbraco v743
Worked great, thanks for the responses.
That is great to hear.
@Jeavon: I was just using the syntax from the Txt Starter Kit,
@James, As you can see in Umbraco you can do things in several ways.
/Dennis.
@Dennis, indeed :-)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Checking if a field is null.
Hello Everyone,
I am trying to test to see if a user has left a certain field null. If they have then i will render one of the other fields as below:
@if(@Umbraco.Field("Field1"){
do this
}
else{
do this
}
I cant test using @RenderLinkIfNotEmpty. And when i look at the cheat sheet is shows .IsNull(property Alias).
What is the best way for me to achieve this?
Kind regards.
Hi James,
I assume that you are doing this directly in the template and not a in partial view maco.
Try this:
If my assumption is wrong, do not hesitate to write again
Hope this helps,
/Dennis
How about
I'm getting true even value is null. Umbraco v743
Worked great, thanks for the responses.
Hi James,
That is great to hear.
@Jeavon: I was just using the syntax from the Txt Starter Kit,
@James, As you can see in Umbraco you can do things in several ways.
/Dennis.
@Dennis, indeed :-)
is working on a reply...