Nizam Nizam

Nizam Nizam

  • NA
  • 11
  • 4.5k

mvc4 how to create download button

Aug 26 2015 12:45 AM
i would like to create a button in my details view .when clicking that button i want to download it from database , i upload it perfectly in my databese
 
 
CONTROLLER:
public ActionResult AddDocument(Document document)
{
if (document.UploadDocument != null)
{
using (var ms = new MemoryStream())
{
document.UploadDocument.InputStream.CopyTo(ms);
document.DocumentImage = ms.GetBuffer();
}
}
db.Documents.Add(document);
db.SaveChanges();
ModelState.Clear();
return View();
 
ACTION:
 
<table class="table table-bordered table-hover document-table">
<thead>
<tr>
<th>SNo</th>
<th class="name">NAME</th>
<th class="description">DESCRIPTION</th>
<th>DOWNLOAD</th>
</tr>
</thead>
@foreach (var item in Model)
{
<tr>
<td>@sn</td>
<td>@Html.DisplayFor(s => item.Name)</td>
<td>@Html.DisplayFor(s => item.Description)</td>
@*<td><button class="btn-info btn download">Download</button></td>*@
@*<td>@Html.ActionLink((s=>item.DocumentImage),"DownloadFile")</td>*@
<td>@Html.ActionLink("Download","DownloadFile")</td>
</tr>
sn++;
}
</table> 
 
 

Answers (1)