简体   繁体   English

无法识别助手中的Razor子表达式

[英]Razor Subexpressions in Helper Not Recognized

I've looked and looked, but I don't think I know the right keywords to find the answer. 我看了看又看,但是我认为我不知道找到答案的正确关键词。 Here is my code: 这是我的代码:

@Html.ActionImage("Index", "Menu", new { menu = "@m.LinkAddr", lang = "en" }, "~/Images/@(m.MainImage)", "@m.Description")

Razor won't recognize any of my inner expressions ( @m.LinkAddr , etc.). Razor无法识别我的任何内部表达式( @m.LinkAddr等)。 I'm using MVC4 VS2010. 我正在使用MVC4 VS2010。

You need to take your expressions out of quotes 您需要将表达式排除在引号之外

@Html.ActionImage("Index", "Menu", new { menu = m.LinkAddr, lang = "en" }, "~/Images/" + m.MainImage", m.Description)

You also don't need the @ , you have that at the begining of the line. 您也不需要@ ,而在行的开头就已经有了。

I'm assuming m is a variable you declared. 我假设m是您声明的变量。 If these are properties on your model, use Model . 如果这些是模型上的属性,请使用Model

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM