To implement the upload file function, sometimes upload will also operate error, can let the user have the opportunity to correct, the development of uploading files can have updated features.
When the file is uploaded, if it is stored in a directory of the application, you need to know some processes when updating, first delete old files, update data table related information, store new files.
This article gives you an idea of how MVC interacts with jquery.
In the database, create a new stored procedure that is updated:
Locate and open FileLibraryEntity.cs, and add a vlid Update method:
In the ExerciseController.cs controller, create an update action:
A tag to delete the old file.
b tag to get the new upload file information.
C tag, save the new upload file.
D tag to update the database.
Next, we modify the views/exercise/filelistmgr.cshtml view:
Tag 1, add a column that lets the user click to update a record.
Tag 2, add a popup dialog box, inside is an upload markup.
Tag 3, referencing the JS and style Library of the popup dialog box.
Tag 4, referencing Uploadify's JS library and style document.
In the jquery code, there are several changes in the following positions:
Tag 5, dynamically produces the button that updates the column.
Mark 6, point to Controller,action.
Tag 7, passing in parameters, in order for the action to know which record the user is updating. (Focus and key)
Demonstrate:
2014-03-22 14:30 Add the following:
MVC series Exercises, the latest source programs and databases, can be downloaded from the link below.
Http://download.cnblogs.com/insus/MVC/InsusMVCSiteCS_Mar22_2014.rar