How MVC in ASP.NET passes data from the background controller to the front view

高洛峰
Release: 2017-01-14 11:42:19
Original
2454 people have browsed it

The example of this article describes the way MVC in ASP.NET transfers data from the background controller to the front view. Share it with everyone for your reference. The specific analysis is as follows:

Data storage model Model:

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; }
}
Copy after login

Front desk receives and displays data view View:

<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: &#39;prev,next today&#39;,
     center: &#39;title&#39;,
     //right: &#39;month,agendaWeek,agendaDay&#39;
     right: &#39;month&#39;
 },
 selectable: true,
 weekMode: &#39;variable&#39;,//fixed,variable,liquid
 events: events,
 defaultEventMinutes: 1440  //默认事件长度为一天
    });
});
</script>
Copy after login

Background processing data controller Controller:

public JsonResult CalendarData()
{
    Operation op = new Operation();
    List<CalendarEvent> calendarData = op.GetData();
    return Json(calendarData, JsonRequestBehavior.AllowGet);
}
Copy after login

I hope this article will be helpful to everyone’s asp.net programming.

For more related articles on how MVC in ASP.NET transfers data from the background controller to the front view, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template