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
Hi guys,
I was wondering how i could compare CurrentPage.template to an id. For instance:
@if(CurrentPage.template == "1079")
The above statement does not give an error, but does not render properly. If i do it like so @if(!CurrentPage.template =="1079") it gives the error:
@if(!CurrentPage.template =="1079")
Operator '==' cannot be applied to operands of type 'bool' and 'string'
So i suppose it has trouble comparing the bool/string output from CurrentPage.template to a number.
Any suggestions?
Thanks in advance,
Lex
Hi Lex
Are you going to check TemplateId?
Use this code:
if (Umbraco.AssignedContentItem.TemplateId == 1079) { }
Alex
Hi Alex,
That was exactly what i was trying to do. And this solution worked perfectly! You are the man!
With kind regards,
You are welcome, Lex!
Have a great day!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How to compare CurrentPage.Template to a number?
Hi guys,
I was wondering how i could compare CurrentPage.template to an id. For instance:
The above statement does not give an error, but does not render properly. If i do it like so
@if(!CurrentPage.template =="1079")
it gives the error:Operator '==' cannot be applied to operands of type 'bool' and 'string'
So i suppose it has trouble comparing the bool/string output from CurrentPage.template to a number.
Any suggestions?
Thanks in advance,
Lex
Hi Lex
Are you going to check TemplateId?
Use this code:
Alex
Hi Alex,
That was exactly what i was trying to do. And this solution worked perfectly! You are the man!
With kind regards,
Lex
You are welcome, Lex!
Have a great day!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.