Here is a part of my Index View for the Explorer Controller where I display the folders and files within the database.
@foreach (UserLoginApp.Models.FolderModel dir in Model.FolderList)
{
<li>
<input id="selectedFolders" 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 id="selectedFiles" type="checkbox" name="selectedFiles" value="@file.Name" />
<img src="~/Content/Images/image.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>
I added checkboxes to all files and folders to be able to make delete operations with them. To do so, I have a partial view inside the page which has an ActionLink to my delete action within the File Controller.
[HttpPost]
public ActionResult Delete(string[] selectedFolders, string[] selectedFiles)
{ //I need to get the selected folder and file names from the checkbox data
// and pass them to the controller action as string arrays.
// I'll do deleting here
return RedirectToAction("Index","Explorer");
}
As a result, I need to pass the checked folder and file name data to the controller action using checkboxes. Also, I want my ActionLink to work as a submit button rather than having an actual button.
I have seen some similar questions on the issue, but couldn't able to come up with a solution. Any help is appreciated :)
Aucun commentaire:
Enregistrer un commentaire