The first parameter is the action name, the second parameter is the controller name @using (html.beginform ("CreateItem", "Knoledge")) { <fieldset> <legend> Knolegemodels</legend> <div class= "Editor-label" > title: <input name= "M_strtitle " class=" /> "Createknoledge" <input name= "M_struserid" class= "Createknoledge" /> Date: <input class= "Easyui-datebox" name= "m_ Dateuploadtime " data-options=" Required:true,showseconds:false " value= "New date ();" style= "width: 150px" /> @Html. ActionLink ("Back to list", "Index") <input type= "Submit" Value= "Create" /> </div> <div class= "Editor-label" > Description: </div> <div class= "Editor-label" > <textarea name= "M_strdesc" class= "Knoledgedesc" ></textarea > </div> </fieldset>}
//each parameter corresponds to the name public actionresult createitem of the View input (string m_ Struserid, string m_strtitle, string m_strdesc, string m_dateuploadtime) { //database operation, is my own encapsulation, can ignore. Dictionary<string, string> _dictParam = new Dictionary<string, string> (); _dictparam.add ("Id", guid.newguid (). ToString ()); _dictparam.add ("M_ strUserID ", m_struserid); _ Dictparam.add ("M_strtitle", m_strtitle); _dictparam.add ("M_strdesc", m_strdesc); _dictparam.add ("M_ Dateuploadtime ", m_dateuploadtime); string _strSql = "Insert into knoledge (id,m_struserid,m_strtitle,m_strdesc,m_ Dateuploadtime,m_strhot) values (: Id,:m_struserid,:m_strtitle,:m_strdesc,to_date (: M_dateUploadTime, ' Yyyy-mm-dd '), 0) "; int iresult = commonfunction.oraexecutenonquery (_strsql, _dictparam); //jump to which view return view ("Create"); }
Less accustomed to the Entity Framework one is the feeling that the native SQL is more controllable, and the second is that EF is not universal enough. (In fact, it is not very clear to play-_-| | | -_-||| )
ASP. NET MVC Individual learning Notes view Pass to Controller