我有一个视图模型,它显示在使用uploadify 的视图中。我需要在帖子中传回收集数据。我怎样才能做到这一点?
视图模型:
public class ViewModel
{
string Name;
IEnumerable<Junk> theJunk;
}
public Junk
{
int id;
string Name;
}
看法:
@model ViewModel
@using (@Html.BeginForm())
{
<input type="file" name="dr405" id="dr405" />
<div>
@Html.LabelFor(model => model.Name)
@Html.EditorFor(model => model.Name)
</div>
@Html.EditorFor(model => model.theJunk)
<input type="submit" value="Upload Junk" />
}
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function () {
jQuery("#dr405").uploadify({
'uploader': '@Url.Content("~/Scripts/uploadify.swf")',
'cancelImg': '/Content/themes/base/images/cancel.png',
'buttonText': 'Browse Files',
'script': 'home/upload',
'folder': '/uploads',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'sizeLimit': '38000',
'multi': true,
'auto': true,
});
});
</script>
控制器:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase fileData, FormCollection collection)
{
// Get my view model here
// ...get the main Name!
// ...get the collection of Junk
return "ok";
}