Reputation: 768
So i have a line in my html like so
someVariable: "@(SomeClass.SomeFunction(SomeParameter))",
But I want to same result without the quatations so it isnt passed in as a string, when i do something like this
someVariable: @(SomeClass.SomeFunction(SomeParameter)),
it does not work, what formatting am i missing here?
Upvotes: 2
Views: 320
Reputation: 1039428
It depends on what does this function returns. If it is some object you could convert it to JSON using the Json.Encode
method:
someVariable: @Html.Raw(Json.Encode(SomeClass.SomeFunction(SomeParameter)),
This will ensure that the value is properly converted to a javascript object and the Html.Raw
helper will ensure that it is left without HTML encoding it.
Upvotes: 2