Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 72416

Trying to access a model object inside a script tag

$
0
0

I'm using Asp.Net Core and trying to reference the model from inside a script tag:

<div>
    <script>
        function calcprices() {                                                
            @Model.Price = document.getElementById("price").value;
        }
    </script>

    <button onclick="calcprices()">Recalculate</button>

The error showing in console window is:

ReferenceError: calcprices is not defined

If I have a look at the debugger, it shows the particular section is missing the Model reference:

function calcprices() {                                                
     = document.getElementById("price").value;
}

So I'm guessing that's why I'm getting an error. Is it not possible to reference a model like this?


Viewing all articles
Browse latest Browse all 72416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>