Skip to content

DevExpress-Examples/asp-net-mvc-upload-control-bind-to-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Upload Control for ASP.NET MVC - Registration form with model binding support

This example demonstrates how to bind UploadControl (its posted files) to a Model property.

public ActionResult Index(UserModel modelDTO) {
    string fileName = string.Empty;
    if (ModelState.IsValid) {
        if (modelDTO.Attachment.Length > 0 && modelDTO.Attachment[0].ContentLength > 0) {
            fileName = string.Format("~/Content/Files/{0}", modelDTO.Attachment[0].FileName);
            modelDTO.Attachment[0].SaveAs(Server.MapPath(fileName));
        }
    }
    SavedModel model = new SavedModel();
    model.UserName = modelDTO.UserName;
    model.FileUrl = fileName;
    return View("Complete", model);
}

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)