在Html.BeginForm中,是否需要将@放在新匿名类型的每个属性之前?除了像@id这样的东西,如果你有其他的properties..custom,你需要为每个添加@吗?我发现,出于某种原因,如果我添加@,编译器将无法识别该属性,而如果我将其去掉,则为does...weird。
示例:
using (Html.BeginForm("GetFileUrl", "Content", FormMethod.Get, new { carId = Model.CarId, userId = Model.UserId, @carFileName = carFile.FileName }))我的操作方法需要参数carId、userId和carFileName
我的路线有Cars/{userId}/{carId}/{carFileName}
发布于 2012-03-31 06:38:16
你可能指的是你在体育课的匿名htmlAttributes中看到的东西。HtmlHelper。你可能已经看到了类似这样的东西:
@Html.ActionLink("link", "index", new { name = "peter" }, new { @class="myclass" })您可以对保留关键字使用@,如string @string = "test"或在我的示例@class中。通常,您应该避免使用这样的保留关键字,但在这种情况下,这是不可避免的。
回答你的问题:只对保留关键字使用它。
https://stackoverflow.com/questions/9950608
复制相似问题