Inline Razor script on Master Template won't get recursive.
Hi All -
I have written the below script:
@{
if (@Model.HasValue("feesCharges")) {
var pickerFC2 = @Model.NodeById(Model._feesCharges);
<div class="col text" onclick="window.open('@pickerFC2.url','_self');">Fees & <span class="black">Charges</span></div>
}
else{
<div class="col text">Fees & <span class="black">Charges</span></div>
}
}
on my Master Template.
Basically it is a content picker - actually it works only on my homepage - but i want it to take the value recursively on interior pages.I have tried to put the _ before the property alias - but seems that i got it wrong - any help on this please.
You're welcome. Do you know that the Razor Macros (DynamicNode) that you are using here is legacy now? If you are using Umbraco v6 or v7 it is recommended you use MVC views/partials directly or Partial View Macro if you really need a macro or are using WebForms instead.
Inline Razor script on Master Template won't get recursive.
Hi All -
I have written the below script:
@{
if (@Model.HasValue("feesCharges")) {
var pickerFC2 = @Model.NodeById(Model._feesCharges);
<div class="col text" onclick="window.open('@pickerFC2.url','_self');">Fees & <span class="black">Charges</span></div>
}
else{
<div class="col text">Fees & <span class="black">Charges</span></div>
}
}
on my Master Template.
Basically it is a content picker - actually it works only on my homepage - but i want it to take the value recursively on interior pages.I have tried to put the _ before the property alias - but seems that i got it wrong - any help on this please.
thanks
//Sam
Hi Sam, you also need to make your HasValue recursive by adding true as a parameter
Additionally it's not a good idea to have @ in your code blocks
Jeavon
Thanks a lot Jeavon - still learning all these razor tricks ; )
You're welcome. Do you know that the Razor Macros (DynamicNode) that you are using here is legacy now? If you are using Umbraco v6 or v7 it is recommended you use MVC views/partials directly or Partial View Macro if you really need a macro or are using WebForms instead.
Nice ... this seems like an interesting way to go..Will surely be digging further into that.
Thanks again.
is working on a reply...