将元素添加到Razor ASP.NET MVC中的列表
我已经声明了list< string>
在我的角度为:
@{
List<string> deletedImages = new List<string>();
}
我有此锚标记: &lt; a href =“ javaScript:void(0)” onclick =“ remove(@item,this)”&gt; x&lt;/a&gt;
和脚本标签:
<script>
function Remove(id, e)
{
@deletedImages.Add(id);
}
</script>
我在@deletedimages.add(id);
说: 名称
id`在当前上下文中不存在。
我该如何解决?
I have declared a List<string>
in my View as:
@{
List<string> deletedImages = new List<string>();
}
I have this anchor tag:<a href="javascript:void(0)" onclick="Remove(@item, this)">X</a>
And the script tag:
<script>
function Remove(id, e)
{
@deletedImages.Add(id);
}
</script>
I'm getting an error in @deletedImages.Add(id);
that says:The name
id` does not exist in the current context.
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论