I am currently on a Dropbox-like MVC4 project and coding the delete action for files and folders. The thing I am wondering is, can I use my Delete ActionLink (which redirects me to the Delete action), as a submit button? Can I pass the checked checkboxes data through Html.ActionLinks to Controllers?
I have a View like this:
[@Html.ActionLink("Download", "Download", "File")]
[@Html.ActionLink("Share", "Share", "File")]
[@Html.ActionLink("Move", "Move", "File")]
[@Html.ActionLink("Rename", "Rename", "File")]
[@Html.ActionLink("Delete","Delete","File")]
[@Html.ActionLink("Copy", "Copy", "File")]
<ul>
@foreach (UserLoginApp.Models.FolderModel dir in Model.FolderList)
{
<li>
<input type="checkbox" name="SelectedFolders" value="@dir.Name" />
<img src="~/Content/Images/Folder-icon.png" alt="Folder Logo" align="top" style="width: 20px;
height: 20px; border: none" />
<a href="@dir.Name/" id="FolderName" title="@dir.Name">@dir.Name</a>
</li>
}
@foreach (UserLoginApp.Models.FileModel file in Model.FileList)
{
<li>
<input type="checkbox" name="SelectedFiles" value="@file.Name" />
@if (file.Name.EndsWith(".jpg") || file.Name.EndsWith(".jpeg") || file.Name.EndsWith(".png"))
{
<img src="~/Content/Images/image.png" alt="File Logo" align="top" style="width: 20px;
height: 20px; border: none" />
}
else
{
<img src="~/Content/Images/file.png" alt="File Logo" align="top" style="width: 20px;
height: 20px; border: none" />
}
<a href="@(uri.AbsolutePath + file.Name)" title="@file.Name" target="_blank">@file.Name</a>
</li>
}
</ul>