如何使用" @"符号在JScript中的MVC剃刀语法? [英] How to use "@" symbol in Jscript in Razor syntax of MVC ?

查看:113
本文介绍了如何使用" @"符号在JScript中的MVC剃刀语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发与剃刀语法​​MVC 3应用程序。

I am developing MVC 3 application with Razor syntax.

我在CSHTML文件拧一个JScript ....
我我想用@在JScript中,但它显示出黄色化背景。

I am wring a Jscript in the cshtml file.... I I want to use @ in the JScript but it showing yellow backgroud.

我婉分配整数值按钮的ID怎么办?

I wan to assign the integer value to button ID how to do that ?

这里是code ...

here is the code...

  success: function (data) {

                $("p.p12").append

                ("<div style=\"background-color:#FAFAFA\";>Recently Added... <br /><a href=\"../../Employee/Details/" + data.OwnerID + "\">" + data.OwnerName + "</a>"
                + data.cmtDateTime + "  <span class=\"EmpName\"><button type=\"button\" id = \" @item.Id \"class=\"deleteComment\">Delete</button></span> <br />" + data.msg + "</div>");

                document.getElementById('Comment').value = "";
                $(".ParentBlock").slideDown("slow");
                $(".ParentBlock").attr("DataCommentId",data.Id);


                $('.ShowComments').text('Hide Comments');

            }

下面是图片...

我应该为@符号呢?

推荐答案

您当前code是正确的。运行它,你会发现它会奏效。至于黄色的花体而言,好了,忽略它,不再信任自动化code编辑器,相信code你写的 - 剃刀智能感知远非完美。希望他们能在未来的版本中改进。

Your current code is correct. Run it and you will see that it will work. As far as the yellow squiggle is concerned, well, ignore it and stop trusting automated code editors, trust the code you write - Razor Intellisense is far from perfect. Hopefully they will improve it in future versions.

由于因为你的code是一个烂摊子地狱(比如你没有属性之间的空间来替代建立这个元素,你可以使用下面的,你已经倒在 ; ,...):

As an alternative to build this element you could use the following because your code is a hell of a mess (for example you don't have spaces between the attributes, you have inverted the ; and ", ...):

$('p.p12').append(
    $('<div/>', {
        style: 'background-color:#FAFAFA;',
        html: 'Recently Added...'
    })
    .append($('<br/>'))
    .append($('<a/>', {
        href: '@Url.Action("Details", "Employee", new { id = "__employeeId__" })'.replace('__employeeId__', data.OwnerID),
        html: data.OwnerName
    }))
    .append(data.cmtDateTime)
    .append($('<span/>', {
        'class': 'EmpName',
        html: $('<button/>', {
            type: 'button',
            id: '@item.Id',
            'class': 'deleteComment',
            html: 'Delete'
        })
    }))
    .append($('<br/>'))
    .append(data.msg)
);

这篇关于如何使用&QUOT; @&QUOT;符号在JScript中的MVC剃刀语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆