How to transfer data from background controller to foreground view by MVC in ASP.NET
This article mainly explains "how to transfer data from the background controller to the foreground view in ASP.NET". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to transfer data from the background controller to the foreground view in ASP.NET.
This paper gives an example of 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 Model:
The copy 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;}
}
The front desk receives and displays the data view View:
The copy code is as follows:
$(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 / / default event length is one day
});
});
Background processing data controller Controller:
The copy code is as follows:
Public JsonResult CalendarData ()
{
Operation op = new Operation ()
List calendarData = op.GetData ()
Return Json (calendarData, JsonRequestBehavior.AllowGet)
}
Thank you for reading, the above is the content of "how does MVC transfer data from the background controller to the foreground view in ASP.NET". After the study of this article, I believe you have a deeper understanding of how MVC in ASP.NET transfers data from the background controller to the foreground view, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!