ASP.Net MVC 3 Razor, Generic Approach for FileUpload Partial View
I have this schema, now i want
-
开发者_如何学运维
In Create View of Artist, I want to use CreatePicture Partial View for uploading picture and saving data in database. And similar for Album controller and all other controller which will use pictureID as foreign key.
On Save button of Create Artist, there should perform three actions simultaneously,
- Insert Picture record in database.
- Save picture's physical file on server.
- Save Artist record in database with newly created pictureID.
I have an open source project that I do most of what you are attempting to do. I host it on Google code.
- Insert Picture record in database.
Here the user selects a picture and clicks save. You could easily turn that into a partial view. see the "customize your profile picture" area http://code.google.com/p/better-task-list-1-1-progress/source/browse/trunk/Views/Account/MyAccount.cshtml
Look at the ChangePicture() ActionResult http://code.google.com/p/better-task-list-1-1-progress/source/browse/trunk/Controllers/AccountController.cs
- Save picture's physical file on server
Look at the code in the ChangePicture() ActionResult http://code.google.com/p/better-task-list-1-1-progress/source/browse/trunk/Views/Account/MyAccount.cshtml
- Save Artist record in database with newly created pictureID.
Look at the code in the ChangePicture() ActionResult http://code.google.com/p/better-task-list-1-1-progress/source/browse/trunk/Views/Account/MyAccount.cshtml
Hope the information above helps you out. take care.
精彩评论