How to insert a value from a ViewBag into an HTML Element via JavaScript

0

I need to pass a value from a viewbag to an HTML element via javascript, and I do not know the correct syntax to do it ... Well, I could pass this value in the traditional way, but I need to set this value via javascript ... Example (this does not work):

script>
    function pegavalor() {
        document.getElementById('CategoriaDescricao').value = @ViewBag.CategoriaDescricao;

    }
</script>
    
asked by anonymous 28.09.2016 / 20:45

0 answers