English 中文(简体)
重载-MVC3:如何通过后继形式收集数据?
原标题:Uploadify - MVC3: How to pass back form collection data?

我有一种看法模式,以使用上载。 我需要将后继数据收集数据退回员额。 我如何能够这样做?

观点:

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";
    }
最佳回答

参看article。 涵盖这一设想。 您可使用<代码>字母Data参数,使您能够向服务器传递额外的价值。 但是,由于上载对每个档案发出多次要求(假设你制定了<条码>多>/代码>选择),你可以采取2项控制行动:首先,每个选定的档案都将被打上,以便在某个地方节省费用,而后一,所有档案一旦上载并发送格式数据,则会很热。 如果你不希望上载在选择档案后立即开始,那么你还应制定<代码>auto的假选择。

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签