Two minor problems encountered in ASP. net mvc development
I recently developed a website using asp.net MVC4.0. Today I encountered two small problems and solved them by searching for relevant channels. Here I wrote these two questions, which is very simple, mark hopes to help beginners who encounter the same problems. Problem 1: I want to implement asynchronous file upload. The files submitted by the front-end cannot be obtained in the background. I wrote it like this: copy the code @ using (Ajax. beginForm ("UpdateNewInfo", "Home", new AjaxOptions () {HttpMethod = "post", OnSuccess = "afterAdd"}, new {id = "form1 "})) {<table> <td> select image </td> <input type = "file" id = "uploadImg" name = "fileUpImg"/> <input type =" button "id =" btnFileUp "value =" Upload image "/> </td> </tr> </table>} copy the code and select an image, click the upload image button to asynchronously upload the image to the server. A Form is submitted and the ajaxSubmit is used to asynchronously upload the file. The backend obtains HttpPostedFileBase postFile = Request. Files ["fileUpImg"]. However, the postFile object is always empty. Check the Form and show data. What is the problem? This problem plagued me for one morning. Then I asked questions in the blog and someone immediately pointed out my mistake. Here is the problem @ using (Ajax. beginForm ("UpdateNewInfo", "Home", new AjaxOptions () {HttpMethod = "post", OnSuccess = "afterAdd"}, new {id = "form1 ", enctype = "multipart/form-data"}) When uploading files, you must set enctype = "multipart/Form-data" for the form ". Why? After checking this attribute, I suddenly realized: QQ20141203214923, I am not surprised, happy, and sad to see it here. What I like is that the problem is solved, sadly, I was troubled by such a problem all morning.  ̄ □ ̄ | Question 2 how to assign values to rich text editor I believe everyone has used Rich Text Editor, I use kindeditor-4.1.7 Rich Text Editor. I edited the content in the editor and stored it in the database. However, when I read the data from the database and assigned a value to Rich Text Using JQuery, it cannot be displayed.