In a razor page, I'd like assign a javascript variable from a model property (not all the model)
I tried several solution but no one works.
This code is plaed at the end of the razor page. The value I get for
<script>
$(document).ready(function () {
var method = @Model.MethodName;
if (!methodd)
alert(method);
);
</script>
I tried this too :
<script>
$(document).ready(function () {
var mName = '';
@if(@Model.MethodName != string.Empty)
mName = @Model.MethodName;
alert(mName);
});
</script>
In the console I get :
var method = ;
Any idea ?
Thanks,
"@Model.MethodName"