In ASP. NET, MVC transmits data from the background controller to the foreground view. asp. netmvc
This article describes how MVC transfers data from the background controller to the foreground view in ASP. NET. Share it with you for your reference. The specific analysis is as follows:
Data Storage Model:
Copy codeThe Code is as follows: public class CalendarEvent
{
Public string id {get; set ;}
Public DateTime start {get; set ;}
Public DateTime end {get; set ;}
Public string backgroundColor {get; set ;}
Public string title {get; set ;}
Public string allDay {get; set ;}
}
Data View displayed on reception desk:
Copy codeThe Code is as follows: <script type = "text/javascript">
$ (Function (){
// Calendar handle data as follows:
Var events = [];
$. Ajax ({
Url: "/DeploymentTask/CalendarData ",
Success: function (data ){
Events = data;
},
Async: false
});
$ ("# Calendar"). fullCalendar ({
Header :{
Left: 'prev, next today ',
Center: 'title ',
// Right: 'month, agendaWeek, agendaDay'
Right: 'month'
},
Selectable: true,
WeekMode: 'variable', // fixed, variable, liquid
Events: events,
DefaultEventMinutes: 1440 // The default event length is one day.
});
});
</Script>
Controller for processing data in the background:
Copy codeThe Code is as follows: public JsonResult CalendarData ()
{
Operation op = new Operation ();
List <CalendarEvent> calendarData = op. GetData ();
Return Json (calendarData, JsonRequestBehavior. AllowGet );
}
I hope this article will help you design your asp.net program.