0

I've created MVC5 application which represent table in web UI, I need that one of the field will be browse text box (or other default control for browse) which user click on it and it open the default browse of windows which he can choose file,how should I do that?

   @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Browse)
                </td>
            </tr>
        }

controller code

    <div class="form-group">
        @Html.LabelFor(model => model.Browse, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Browse)
            @Html.ValidationMessageFor(model => model.Browse)
        </div>
    </div>
mileyH
  • 176
  • 1
  • 5
  • 20
  • 2
    By "browse" you mean you want a file upload input? See http://stackoverflow.com/questions/5193842/file-upload-asp-net-mvc-3-0 – Steve Howard Mar 30 '14 at 18:43
  • @SteveHoward-Thanks I already saw this post but I want to add it as part of table (like in the post for second field )how should I do that? can you please provide example – mileyH Mar 30 '14 at 18:54

1 Answers1

1

If you want define it many times in loop inside table, try something like this:

@foreach (var item in Model)
{
       <tr>
           <td>
               @Html.DisplayFor(modelItem => item.name)
           </td>
           <td>
               @Html.DisplayFor(modelItem => item.Browse)
               <input type="file" name="@item.Browse" />
           </td>
       </tr>
}
Jeyhun Rahimov
  • 3,769
  • 6
  • 47
  • 90