Developer forum

Forum » Templates » Cookie level in razor/cshtml ?

Cookie level in razor/cshtml ?

Lise T. Pedersen
Reply

I need to put some script into an if-sentence on a razor masterpage ("if cookie level option = all") But I can't make it work as cshtml.

I hope some of you will make a copy of the code snippet and put it here - thanks in advance!!

/LTP


Replies

 
Nicolai Pedersen
Reply

Like this:

if(Dynamicweb.Environment.CookieManager.GetCookieOptInLevel() = Dynamicweb.Environment.CookieOptInLevel.All){
//Option is all
}
 
Aki Ruuskanen
Aki Ruuskanen
Reply

Someting like this :

 

@if (GetGlobalValue("Global:Area.ID") == 'All')
{
//Stuff
}
 
Lise T. Pedersen
Reply

Thank you - I tried both versions. Forgot to tell, that I am working with a wrap-solution. Should that make a difference? Perhaps a totally other way of doing it?

Here is my code in the head of the master.cshtml:

@if(Dynamicweb.Environment.CookieManager.GetCookieOptInLevel() = Dynamicweb.Environment.CookieOptInLevel.All){
 @GetValue("Item.Area.OtherAnalyticsCode")
}

And the error - regarding another template:

Error compiling template "Designs/Dwsimple/_parsed/fullwidth.parsed.cshtml"
Line 1939: The left-hand side of an assignment must be a variable, property or indexer

/Lise

 
Aki Ruuskanen
Aki Ruuskanen
Reply
This post has been marked as an answer

@if(Dynamicweb.Environment.CookieManager.GetCookieOptInLevel() == Dynamicweb.Environment.CookieOptInLevel.All){
 @GetValue("Item.Area.OtherAnalyticsCode")
}

Votes for this answer: 1
 
Nicolai Pedersen
Reply

Woops...

 

You must be logged in to post in the forum