Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 2.45 KB

File metadata and controls

38 lines (32 loc) · 2.45 KB

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)