A demo made by ASP. net mvc + colorbox (2)

Source: Internet
Author: User
Next, we need to modify our resume.

First, add two actions to resumecontroller:Code:

 /// Get:/resume/edit/5  Public  Actionresult Edit ( Int ID) {resume. models. Resume Resume = context. resumes. Find (ID); viewbag. nationid = New  Selectlist (Context. nations, "Nationid" , "Name" , Resume. nationid ); Return View (resume );} /// Post:/resume/edit/5 [ Httppost ] Public  Actionresult Edit (resume. models. Resume Resume ){ If (Modelstate. isvalid) {context. Entry (resume). State = Entitystate . Modified; context. savechanges (); Return Redirecttoaction ( "Index" );} Return View (resume );}

Second, create edit. cshtml. Select empty, just like create. cshtml.

Third, add the following code to index. cshtml:

 
$ ("A [rel = 'editresume ']"). Click (Function() {$ (This). Colorbox ({width: 1000, heigth: 500, overlayclose:False, Close:"", Oncomplete:Function() {$ ("# Btncancel"). Click (Function() {$. Colorbox. Close () ;}) ;}, onclosed:Function() {$. Colorbox. Remove ();}});});

Fourth, running effect:

Resume details

First, add action.

/// Get:/resume/details/5PublicActionresultDetails (IntID) {resume. models.ResumeResume = context. resumes. Find (ID );ReturnView (resume );}

Second, create details. cshtml, as above.

Third, the running effect:

Resume Deletion

First, add action.

PublicActionresultDelete (IntID) {resume. models.ResumeResume = context. resumes. Find (ID); context. resumes. Remove (resume); context. savechanges ();ReturnRedirecttoaction ("Index");}

Create an action.

Second, the running effect:

Add work experience

The above functions are very simple, and this function is not difficult,

First, start with adding an action.

  Public   viewresult  addexper ( int  ID) {viewbag. expersbyid = context. experiences. where (E => E. resumeid = ID);  return  View ();} [ httppost ]  Public   actionresult  addexper (resume. models.  experience  exper) { If  (modelstate. isvalid) {exper. resumeid =  convert . toint32 (routedata. values [ "ID" ]); context. experiences. add (exper); context. savechanges ();  return  redirecttoaction (" Index ") ;}< span style =" color: Blue; "> return  View (exper) ;}

Second, create addexper. cshtml. The Code is as follows:

 <  Body  >  @  Using (Html. beginform ()){ <  Table  > <  Tr  > <  Th  > Start Time </  Th > <  Th  > End Time </  Th  > <  Th  > Work Unit </  Th  > <  Th  > Certifier </ Th  > </  Tr  >  @  Foreach ( VaR Item In Viewbag. expersbyid ){ <  Tr  > <  TD  >  @ Item. starttime. tostring ("Yyyy-mm-dd" ) </  TD  > <  TD  >  @ Item. endtime. tostring ( "Yyyy-mm-dd" ) </  TD  > <  TD  >  @ Item. workunit </  TD  > <  TD  >  @ Item. Voucher </  TD  > </  Tr  > } <  Tr  > < TD  >  @ Html. editorfor (E => E. starttime) @ Html. validationmessagefor (E => E. starttime) </  TD  > <  TD  >  @ Html. editorfor (E => E. endtime) @ Html. validationmessagefor (E => E. endtime) </ TD  > <  TD  >  @ Html. editorfor (E => E. workunit) @ Html. validationmessagefor (E => E. workunit) </  TD  > <  TD  >  @ Html. editorfor (E => E. voucher) @ Html. validationmessagefor (E => E. voucher) </  TD  > </  Tr  > </  Table  > <  P  Style  ="  Text-align  : Center; "> <  Input  Type  = "Submit"  Value = "Add"/> <  Input  Type  = "Button"  ID  = "Btncancel"  Value  = "Cancel"/> </  P  > } </  Body  > 

Third, add the following code to index. cshtml:

$ ( "A [rel = 'addexper ']" ). Click ( Function () {$ (This ). Colorbox ({width: 950, overlayclose: False , Close: "" , Oncomplete: Function () {$ ( "# Starttime, # endtime" ). Datepicker ({changemonth: True , Changeyear: True , Daynamesmin :[ 'Day' , '1' , '2' , '3' ,'4' , '5' , '6' ], Monthnamesshort :[ 'August 11' , 'August 11' , 'August 11' , 'August 11' , 'August 11' , 'August 11' , 'August 11' , 'August 11' , 'August 11' , 'August 11' ,'August 11' , 'August 11' ], Dateformat: 'Yy-mm-dd' , Yearrange: 'C-50: C + 50' , Showmonthafteryear: True }); $ ( "# Btncancel" ). Click ( Function () {$. Colorbox. Close () ;}) ;}, onclosed: Function () {$. Colorbox. Remove ();}});});

Fourth, let's take a look at the running effect:

Summary

After a small demo is completed, I learned a lot in this process. Once again, I firmly believe that practice is the best way to learn. Of course, I still have a lot of questions in this demo. If you are interested, you can ask me to learn and improve together.

DemoSource code: Http://files.cnblogs.com/nianming/Resume1.rar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.