Write in front
The previous article implemented the ability to create folders, which would implement the ability to click a folder and load the list.
Series Articles
[Ef]vs15+ef6+mysql Code First mode
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (1)
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (2)--User Registration
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (3)--Verification code
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (4)--Upload Avatar
[Bootstrap]modal Popup box
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (5)--login interface, avatar and other proportional compression
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (5)--page template
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (5)--ajax mode registration
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (6)--ajax mode login
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (7)--File upload
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (8)--File download, delete
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (9)--Edit file name
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (10)--New Folder
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (11)--New Folder 2
Code Snippets
Consider the use of a non-refreshing way, stitching HTML tags is more troublesome, here is the traditional way directly. Front-End Code:
<TDclass= "Even sorting_1"> <ahref= "[email protected]"ID= "[email protected]"onclick= "Clickfolder (' [email protected] ')"> <imgsrc= "@item. Fileicon "alt= "@item. FileName " /> <spanID= "[email protected]"Path= "@item. FilePath ">@item. FileName</span> </a> </TD>
Updates the logic of the load list.
[HttpGet] PublicActionResult FileList () {UserInfo UserInfo= session["User"] asUserInfo; if(UserInfo = =NULL) { returnRedirecttoaction ("Login","UserInfo"); } stringFolderPath = request.params["Path"]; Expression<func<myfile,BOOL>>where=NULL; if(string. IsNullOrEmpty (FolderPath)) {where= x = = X.user.id = = Userinfo.id &&!X.isdelete; } Else { where= x = X.user.id = = userinfo.id &&!x.isdelete && x.filepath.startswith (folderpath) && X.filep Ath! =FolderPath; } varFileList = _myfileservicerepository.findall (where). (x = X.isfolder). OrderByDescending (x =X.createdt); Viewbag.userinfo=UserInfo; Viewbag.childtitle="my net drive."; returnView (fileList); }
Update the logic of the new folder to get the current directory from the URL
//Create a folder$('#btnNewFolder'). Click (function () {//Set PopOver title vartitle = $ ('#alertTitlte'). html (); //get the current directory from the URL varURL =window.location.href; Console.log (URL); if(Url.indexof ('Path') >1) { $('#hdFilePath'). Val (Url.split ('=')[1]); }; $('#alertTitlte'). HTML ('New Folder'); //empty pop-up box contents$(". Modal-body"). HTML ("'); $(". Modal-body"). HTML ('<input type= "text" placeholder= "Please enter name" class= "Form-control" name= "name" value= "new Folder" id= "Txtfilename"/> '); $('#txtFileName'). Val ("'); $('#modal-edit'). Modal ('Show'); $('#txtFileName'). Val ('New Folder'); $('#lnkSave'). Unbind ('Click'); $('#lnkSave'). Bind ('Click', function () {$.post ('CreateFolder', {folderName: $ ('#txtFileName'). Val (), FolderPath: $ ('#hdFilePath'). Val ()}, function (data) {data=json.parse (data); varfolder =Data.folder; if(Data.code = = $) { $('<tr class= "odd" > <td class= "even sorting_1" id= "FileName" > <a href= "#" id= "lnkfolder-'+ folder. Id +'"onclick=" Clickfolder (sp-'+ folder. Id +') ">'+ folder. FileName +'</a></td><td class= "center" ></td><td class= "center" >'+ curenttime () +'</td><td class= "center" ><a class= "btn btn-info" href= "#" id= "Fileedit" > <i class= "Glyphicon Glyphicon-edit icon-white "></i> edit </a><a class=" btn Btn-danger "href=" # "><i class= "Glyphicon glyphicon-trash icon-white" id= "filedelete" ></i> Delete </a> </td></tr>'). InsertBefore ($ ('#fileList tbody')); }; //Restore PopOver Title$('#alertTitlte'). HTML (title); }); }); });
Test
Summarize
Select the contents of the new content to update here, the following will be for uploading files and new directory features to be combined, so that upload files to the new directory.
Actual combat MVC5+EF6+MYSQL Enterprise Network Disk Combat (11)--New Folder 2