How Can I get sitecore value and replace the js variable with that value ? in asp.net
ex: Assume sitecore field value is 4 then I need to get this value to a variable and replace the js with this value.
How Can I get sitecore value and replace the js variable with that value ? in asp.net
ex: Assume sitecore field value is 4 then I need to get this value to a variable and replace the js with this value.
For example, if on the current item you have a field Title
and you want to assign its value to a JavaScript variable, you can use this code:
<script type="text/javascript">
var title= '@Sitecore.Context.Item["Title"]';
</script>
I tried it in an MVC solution and it works fine.
And for ASP.NET WebForms, try this:
<script type="text/javascript">
var title = '<%= Sitecore.Context.Item["Title"] %>';
</script>