Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 @在Html.BeginForm的匿名方法中_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 @在Html.BeginForm的匿名方法中

Asp.net mvc 3 @在Html.BeginForm的匿名方法中,asp.net-mvc-3,Asp.net Mvc 3,在Html.BeginForm中,是否需要将@放在新匿名类型的每个属性之前?除了像@id这样的东西,如果你有其他属性呢..自定义,你需要为每个属性添加@吗?我发现无论出于什么原因,如果我添加@编译器不识别这个属性,如果我去掉它,它会识别…奇怪 例如: using (Html.BeginForm("GetFileUrl", "Content", FormMethod.Get, new { carId = Model.CarId, userId = Model.UserId, @carFileNam

在Html.BeginForm中,是否需要将@放在新匿名类型的每个属性之前?除了像@id这样的东西,如果你有其他属性呢..自定义,你需要为每个属性添加@吗?我发现无论出于什么原因,如果我添加@编译器不识别这个属性,如果我去掉它,它会识别…奇怪

例如:

using (Html.BeginForm("GetFileUrl", "Content", FormMethod.Get, new { carId = Model.CarId, userId = Model.UserId, @carFileName = carFile.FileName }))
我的操作方法需要参数carId、userId和carFileName


我的路线有车/{userId}/{carId}/{carFileName}

你可能指的是你在《HtmlHelper》的匿名htmlAttributes中看到的东西。 你可能会看到这样的情况:

@Html.ActionLink("link", "index", new { name = "peter" }, new { @class="myclass" })
您可以使用@作为保留关键字,如string@string=test或我的示例中的@class。通常,您应该避免使用这样的保留关键字,但是在这种情况下,这是不可避免的


回答您的问题:仅用于保留关键字。

不确定您指的是什么。你能给出一个代码示例吗?