简体   繁体   中英

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.). I'm using 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. If these are properties on your model, use Model .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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