Ive been trying to get Macro Parameters in JavaScript with Razor for a few hours now, with no luck. Is it even possible? Havent been able to Google any answers so I thought Id ask here. Hope someone can help.
Not sure I get the the context? What are you trying to achieve? You can generate JavaScript using some Razor code but it's mixing up things so you have some JavaScript logic in a Razor view file, which may not be nice...but sometimes that's of course the option one needs to go with for different reasons.
A better approach could be to add some custom data-* attributes to some HTML elements, which you can use to expose some values that you can then fetch using JavaScript. But in order to be able to point you in the correct direction you'll need to elaborate a bit more on why, what and how you need to achieve it and perhaps share some of the code that you're currently trying to get to work.
Macro Parameters in JavaScript?
Ive been trying to get Macro Parameters in JavaScript with Razor for a few hours now, with no luck. Is it even possible? Havent been able to Google any answers so I thought Id ask here. Hope someone can help.
Hi Severin
Not sure I get the the context? What are you trying to achieve? You can generate JavaScript using some Razor code but it's mixing up things so you have some JavaScript logic in a Razor view file, which may not be nice...but sometimes that's of course the option one needs to go with for different reasons.
A better approach could be to add some custom data-* attributes to some HTML elements, which you can use to expose some values that you can then fetch using JavaScript. But in order to be able to point you in the correct direction you'll need to elaborate a bit more on why, what and how you need to achieve it and perhaps share some of the code that you're currently trying to get to work.
Looking forward to hearing from you.
/Jan
is working on a reply...