asp.net MVC Colorbox Simple example Demo

Source: Internet
Author: User
First, add two action in the Resumecontroller, as in the following code:
 
   
 
  code is as follows copy code
 ////Get:/RESUME/EDIT/5  public actionresult Edit (int id) {Resume.Models.Resume re Sume = 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 (Mod Elstate.isvalid) {context. Entry (Resume).
        state = entitystate.modified; Context.
        SaveChanges ();
    Return redirecttoaction ("Index");
Return View (Resume); }
Second, create edit.cshtml, just like creating create.cshtml, select empty.
Third, add the following code to the index.cshtml:
 
  
  
The code is as follows Copy Code
$ ("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 ()
    ;}})
;
Four, the operation effect:
More information about your resume
First, add the action.
  
   
  
The code is as follows Copy Code
////Get 
:/RESUME/DETAILS/5

public actionresult Details (int id)
{
    Resume.Models.Resume Resume = context. Resumes.find (ID);
    Return View (resume);
}
Second, create details.cshtml, ditto.
Third, the operation effect:
The deletion of the resume
First, add the action.
 
  
  
The code is as follows Copy Code
Public ActionResult Delete (int id)
{
    Resume.Models.Resume Resume = context. Resumes.find (ID);
    Context. Resumes.remove (resume);
    Context. SaveChanges ();
    Return redirecttoaction ("Index");
}
Creating the action is OK.
Second, the operation effect:
Add Work Experience
The above features are very simple, this function is not difficult,
First, start by adding an action.
 
  
  
  code is as follows copy code
 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) {exp Er.
        Resumeid = Convert.ToInt32 (routedata.values["id")); Context.
        Experiences.add (Exper); Context.
        SaveChanges ();
    Return redirecttoaction ("Index");
Return View (Exper); 
Second, create addexper.cshtml with the following code:
 
 
The code is as follows Copy Code
<body>@using (Html.BeginForm ()) {<table> <Tr> <Th>Start Time </th> <Th>End Time </th> <Th>Work Unit </th> <Th>Proof of human </th> </Tr>@foreach (var item in Viewbag.expersbyid) {&LT;TR> <Td>@item. Starttime.tostring ("Yyyy-mm-dd") </td> <Td>@item. Endtime.tostring ("Yyyy-mm-dd") </td> <Td>@item. Workunit </td> <Td>@item. Voucher &LT;/TD> </Tr>} <tr> <Td>@Html. Editorfor (e => e.starttime) @Html. Validationmessagefor (E => e.starttime) & Lt;/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"/&GT;&LT;/P&GT;} </body>
Third, add the following code to the index.cshtml:
 
 
The code is as follows Copy Code

$ ("a[rel= ' Addexper ']"). Click (function () {$ (this). Colorbox ({width:950, overlayclose:false, close: ", Oncomplete:fun Ction () {

$ ("#StartTime, #EndTime"). DatePicker ({

Changemonth:true, Changeyear:true,

Daynamesmin: [' Day ', ' one ', ' two ', ' three ', ' four ', ' five ', ' six '],

Monthnamesshort: [' January ', ' February ', ' March ', ' April ', ' May ', ' June ', ' July ', ' August ', ' September ', ' October ', ' November ', ' December '],

DateFormat: ' Yy-mm-dd ', Yearrange: ' c-50:c+50 ', showmonthafteryear: true };

$ ("#btnCancel"). Click (function () {$.colorbox.close ();}); }, Onclosed:function ()

{$.colorbox.remove ();} }); });

Four, look at the effect of the operation:
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.