input values Filename ways to render and send it to a controller: You need to see some MVC3 conferences (I NerdDinner a good Form the tutorial, start the tutorial), but here's a somewhat similar approach to what you want to do: Your model will look like (and I'm in doubt here because you start installing dynamic controller and action, which is unusual): For now controls: Note: I am garbage in syntax, so you have to check this, but Visual Studio should tell you what works.
& lt; Div id = "fileuploaddiv" class = "fileuploaddivclass" & gt; & Lt; Form action = "@model.form_action" method = "@model.form mode" enquept = "@model.form encryption type" & gt; & Lt; Input type = "hidden" name = "key" value = "upload / $ {filename}" id = "file name" /> & Lt; Input type = "hidden" name = "AWSAccessKeyId" value = "@model.AWSAccessKey" /> & Lt; Input type = "hidden" name = "content-type" value = "image / jpeg" & gt; & Lt; Div & gt; Please specify a file, or a set of files: & lt; Input type = "file" name = "file" /> & Lt; / Div & gt; & Lt; Input type = "submit" value = "upload" / & gt; & Lt; / Form & gt; & Lt; / Div & gt; The
@model Your VoO model & lt; Div id = "fileuploaddiv" class = "fileuploaddivclass" & gt; @ Use (Html.BeginForm (Model.FormAction, Model.FormController, FormMethod.Post) @ Html.HiddenFor (model.key = & gt; $ {fileName}) @ HTML. HiddenFor (model.AWSAccessKeyID) @ Html.HiddenFor ( model .Content- type) @ & LT; input type = "submit" value = "My form Submit" / & gt; @ Html.EndForm () & lt; / div & gt;
public class YourViewModel {public string FormAction { Get; set;} public service Ring in the form Controller {; set;} public Inc. AWSAccessKeyID {get; set;} public string Content-Type {get; set;}}
[HttpGet] public ActionResult WhateverControllerName () {YourViewModel yvm = new YourViewModel (); // Initalize here Viewmodel (Yvm) Return scene;} [HttpPost] public ActionResult WhateverControllerName (YourViewModel yvm) {if (ModelState .IsValid) {// Do whatever you like, do this. Probably a redirect?} Look again (yvm); }
Comments
Post a Comment