0

I have a simple modal as follows,

public class Student{
 public string Name;
 public HttpPostedFileBase file;
// and some other properties of student
}

Required potion of view as follows,

@model Student

@using (Html.BeginForm("Index", "Student", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ 
    <input type="file" name="file" />
    <input type="submit" name="Submit" id="Submit" value="Upload" />

/*complex javascript based user selection would not erase when user click on submit button*/

}

My post methord as follows,

    [HttpPost]
    public ActionResult Index(Student student){

//post data to the server and need got the feed back of save status success or fails. Based on that, some potuon of Ui need to change.

return View(student);
//ooh my complex ui erased.
}

As I describ the problem inside the code how can I overcome from the situation.

You might suggess that you can use ajax action methord here. But witch cannot use since i have need to sent post file to action.

I think this is impossible to make it happen but it is common problem.

Appriciate your suggession to make this work.(I can't use iframe here)

ssilas777
  • 9,672
  • 4
  • 45
  • 68
Prageeth godage
  • 4,054
  • 3
  • 29
  • 45
  • 1
    `You might suggess that you can use ajax action methord here. But witch cannot use since i have need to sent post file to action.` That frankly makes no sense. If you want to do this without refreshing the page you *have* to use AJAX, and the method of the request makes no difference to this. – Rory McCrossan Jul 28 '16 at 14:53
  • Also, when you have to post a file, you need to have a parameter of type `HttpPostedFileBase` to accept that in your http post action method (or as view model property) – Shyju Jul 28 '16 at 14:55
  • Can i feed to HttpPostedFileBase by ajax directly to mvc controller? – Prageeth godage Jul 28 '16 at 14:57

0 Answers0