forum

Home / DeveloperSection / Forums / How to use model value in javascript in razor view

How to use model value in javascript in razor view

Hemant Patel 995 06-Dec-2017

Here is my code but i am not able to use model value in java script code.

@model IEnumerable<MindStickInterview.Web.Models.MarksDetails>


<div class="modal-content">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title"></h4>
    </div>
    <div id="piechart" style="width: 600px; height: 400px"></div>
    <div class="modal-footer">
        <button type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>
    </div>
</div>

<script>
    google.charts.load('current', {
        packages: ['corechart']
    });
    google.charts.setOnLoadCallback(drawChart);


    function drawChart() {

        var data = new google.visualization.DataTable();
        var total = 0;

        data.addColumn('string', 'InterviewPapers');
        data.addColumn('number', 'InterviewMarks');

        //for (var i = 0; i < model.length; i++) {
        // data.addRow(["Correct " + model[i].Type + " Questions" + " (" + model[i].Marks + ")", model[i].Marks]);
        // //data.addRow([" InCorrect " + model[i].Type + " Questions" + " (" + model[i].InCorrectQuestions + ")", model[i].InCorrectQuestions]);
        // total = parseInt(model[i].InCorrectQuestions) + parseInt(model[i].Marks);
        // data.addRow(["Total " + model[i].Type + " Questions" + " (" + total + ")", total]);
        //}

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        var options = {
            title: "",
            position: "top",
            fontsize: "14px",
            is3D: true,
            width: 650,
            height: 450,
            pieSliceText: 'value',
            sliceVisibilityThreshold: 0
        };

        chart.draw(data, options);
    }
</script>




c# c#  mvc4 
Updated on 06-Dec-2017
Exploring the online world is my passion. have experience of #content writing #SEO #Digital Marketing #On-Page #Lead Generation #Content Analyst #Marketing Analyst... I could never stop at one point, continuously wanted to acquire more and more skills. My work for any organization will be full of passion and hard work.

Can you answer this question?


Answer

1 Answers

Liked By