I need to add the following field at my form
<input type="file" class="input-file" />
I create model and describe this field (the last field)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace CorePartners_Site2.Models
{
public class FeedbackForm
{
public string Name { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public string Company { get; set; }
public string AdditionalInformation { get; set; }
public HttpPostedFileBase ProjectInformation { get; set; }
}
}
and create
@Html.TextBox(null, null, new { type="file", @class="input-file" })
but it doesnt work, I get some exception. What's wrong?
@Html.TextBox("ProjectInformation", null, new { type="file", @class="input-file" })@Html.TextBox("file", null, new { type="file", @class="input-file" })and I get<input class="input-file" id="file" name="file" type="file" value="">but I dont need id here. How to create the field without id?ProjectInformationfor id, then mvc will bind file to your model automaticly.