Developer forum

Forum » Development » Template.SetTag/SetTagValue not working with Razor

Template.SetTag/SetTagValue not working with Razor

Jonas Mersholm
Reply

Hi there.

I am extending the OnGlobalTags notification.

Here i am setting some template tags

pageviewNotificationArgs.Template.SetTag("Dealer.Name", U.Name);

I can easily get this value in my template by using

<!--@Dealer.Name-->

But the razor equivalent 

@GetValue("Dealer.Name")  does not work.

 

Neither does it if i try to use the SetTagValue method, using an object as a value.

 

Any idea whats going on?

Thanks in advance

Jonas


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

In Razor you have to use @GetGlobalValue to get the value of a global tag:

@GetGlobalValue("Dealer.Name")

Alternatively, you can access any global values through the Pageview object

@Pageview.GlobalTags.GetTagByName("Dealer.Name").Value

 

Best regards,
Mikkel

Votes for this answer: 1

 

You must be logged in to post in the forum