If we write the following code directly in a cshtml file:
<script>
var xzz = '@Method1("abc", "test5")';
</script>
Then the @Method1 helper functions processes the data and returns a string. The output of the block is as following:
<script>
var xzz = 'abc test5';
</script>
Which is as expected.
But if the script block comes from the database (in a property of the model) then can't seem to have the helper method (@Method1) or any Razor syntax processed. The output is as following (in the view source). Which is not the expected output:
<script>
var xzz = '@Method1("abc", "test5")';
</script>
The expected output should be:
<script>
var xzz = 'abc test5';
</script>
I have tried the followings:
@MvcHtmlString.Create(Html.Raw(Model.property1).ToString())
Html.RenderPartial("_localizer", Model.property1);
//The _localizer is a cshtml file
Html.Raw(Model.property1)
@MvcHtmlString.Create(Html.Raw(Model.property1).ToString())
None of them seems to be working.