0

I have a Model that contains Date of the report.

On a click, I want to display the report for that date in the popup.

I have the following logic:

 Click to view Report <button type='button' class='k-button btn-icon-sm btn-hyperlink' id='btnViewRpt' onclick='ViewRptData()'><span class='k-icon k-i-hyperlink-open-sm'></span></button>

Then I have a script that calls a function:

<script>

    function ViewRptData()
    {
        var test = {@Model.FileDate}
        alert(test);
    }

</script>

When clicking on the button, I'm getting a console error:

SCRIPT1003: Expected ':'

What am I doing wrong?

1 Answer 1

1

You need to set your model property into a property of the javascript object.

 var test = { fileDate: '@Model.FileDate'};
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that's exactly what I was looking for

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.