MVC 视图中的语法错误

Syntax Error in MVC view

这个在 @question

处给我一个语法错误

这里有什么问题?

@{
    string question = "Really delete?";

<link href="~/Content/sweetalert/sweetalert.css" rel="stylesheet" />
<script src="~/Content/sweetalert/sweetalert.min.js"></script>
<script>
    $(function () {
        $(".delete").on("click", function (e) {
            swal({
                text: @question,
                title: "Delete Confirm",
                //some other stuff...

}

你必须这样使用questiontitle: "@question"

代码:

@{
    string question = "Really delete?";
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <link href="~/Content/sweetalert.css" rel="stylesheet" />
    <script src="~/Content/sweetalert.min.js"></script>
    <script>
        $(function() {
            $(".delete").on("click", function(e) {
                swal({
                    title: "@question",
                    text: "You will not be able to recover this imaginary file!",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "Yes, delete it!",
                    closeOnConfirm: false
                });
            });
        });
    </script>

}

text: @question,应该像这样包裹在 ''

text: '@question'