如何将数组传递给控制器?
我有表单
@using (Html.BeginForm("Create", "StoreManager"))
{
@Html.ValidationSummary(true)
//etc..
}
用户将图像上传到服务器,上传完成后立即创建缩略图并以这种格式动态添加到表单中:
<div class="gridItem">
<div><img src="image1.jpg" class="gridThumb" /></div>
<div class="gridTitle">
<a href="/Store/del?image1.jpg" class="ui-icon ui-icon-trash"></a>
</div>
</div>
<div class="gridItem">
<div><img src="image2.jpg" class="gridThumb" /></div>
<div class="gridTitle">
<a href="/Store/del?image2.jpg" class="ui-icon ui-icon-trash"></a>
</div>
</div>
我的问题是:如何在控制器操作中从该网格获取所有图像文件的列表? 我想将此列表保存在模型中。
I have form
@using (Html.BeginForm("Create", "StoreManager"))
{
@Html.ValidationSummary(true)
//etc..
}
User uploads images to server and when upload is completed immediately thumbnail image is creating and dynamically added to the form in this format:
<div class="gridItem">
<div><img src="image1.jpg" class="gridThumb" /></div>
<div class="gridTitle">
<a href="/Store/del?image1.jpg" class="ui-icon ui-icon-trash"></a>
</div>
</div>
<div class="gridItem">
<div><img src="image2.jpg" class="gridThumb" /></div>
<div class="gridTitle">
<a href="/Store/del?image2.jpg" class="ui-icon ui-icon-trash"></a>
</div>
</div>
my question is: how I can get list of all image files from this grid in controller action?
I want to save this list in model.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你想保存图像位置而不是二进制图像本身。
假设您的控制器操作如下所示,
我不确定如何生成 html,但您也可以为每个图像添加一个隐藏字段,如下所示:
然后,当您发布表单时,您应该收到操作参数数组。
如果您有其他要求,请告诉我。
I guess you want save the images location and not the binary image itself.
Lets say your controller action looks like this
I'm not sure how you generate your html, but you could also add a hidden field for each image like this :
Then when you post your form, you should receive the array on action parameter.
If you have another requirement, please let me know.