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
I have tried this:
<script type="text/javascript">
function foo() { var myprop = '<umbraco:item field="propField" runat="server" />'; }</script>
comes back empty
then I tried this:
function foo() { var myprop = '<%= umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("myProp").Value %>'; }</script>
for some reason GetCurrent() does not return the current page but the home page?
any ideas
maybe this examples will help:
this example is a working code inside razor macro:
<script type="text/javascript"> @{ var rootNode = Model.AncestorOrSelf(1); var thankYouNode = rootNode.ThankYouPage.First(); } var thankYouUrl = "@umbraco.library.NiceUrl(thankYouNode.Id)";</script>
and this is working code inside xslt macro:
<script type="text/javascript">var languageID = "<xsl:value-of select='$languageID' />";</script>
now you change the values that you need for your purpose, for example get the CurrentModel properties, etc.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How can set a js var to the value of a page property of the current page
I have tried this:
<script type="text/javascript">
function foo()
{
var myprop = '<umbraco:item field="propField" runat="server" />';
}
</script>
comes back empty
then I tried this:
<script type="text/javascript">
function foo()
{
var myprop = '<%= umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("myProp").Value %>';
}
</script>
for some reason GetCurrent() does not return the current page but the home page?
any ideas
maybe this examples will help:
this example is a working code inside razor macro:
and this is working code inside xslt macro:
now you change the values that you need for your purpose, for example get the CurrentModel properties, etc.
is working on a reply...