In mvc, you pass data from the background controller (Controller) to the foreground Page view (view) __net

Source: Internet
Author: User

Mode one:

Data storage Model:

public class Calendarevent
        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;}
View Code

foreground receives display Data views View:

<script type= "Text/javascript" >
        $ (function () {
            //calendar handle data as follows:

            var events = [];
  $.ajax ({
                URL: "/deploymenttask/calendardata",
                success:function (data) {
                    events = Data

            $ ("#calendar"). Fullcalendar ({

                header: {left
                    : ' Prev,next today ',
                    Center: ' title ',
                    //right: ' Month,agendaweek,agendaday ' right
                    : ' Month '
                weekmode: ' Variable ',//fixed, Variable,liquid
                defaulteventminutes:1440  //default event length of one day
    ; </script>
View Code

Background processing Data Controller controller:

public class Deploymenttaskcontroller:controller
        jsonresult calendardata ()
            Operation op = New Operation ();

            List<calendarevent> calendardata = Op. GetData ();

            Return Json (CalendarData, jsonrequestbehavior.allowget);

View Code

Data style screenshot in transmission:

Mode two:

Data storage Model Models: This method does not use model storage, which is to pass strings string data (including string JSON data) to foreground page view views, using the model for data storage when passing JSON-type data. This is implemented using the string concatenation method
foreground receives display Data views View:

<script type= "Text/javascript" > $ (document). Ready (function () {var inidata = [];
                    $.ajax ({url: '/modifyinifile/showinifiledata ', success:function (data) {
                Inidata = data;
            }, Async:false});
                $ (' #tt '). Tree ({method: ' Get ', Data:inidata, Checkbox:true,
                    Lines:true, Animate:true, Oncheck:function (node,checked) {
                    alert (node.checked);
                    alert (;
                    Changekeydata = Node.text;

                    Changevaluedata = node.checked; Changedata + + "*" +changekeydata + "|"
                + Changevaluedata;
        }, Onlyleafcheck:true, cascadecheck:false});}); </script>
View Code

Background processing Data Controller controller:

public class Modifyinifilecontroller:controller {////Get

        Contentresult Showinifiledata ()

            string jsondata = Op. Getinifiledata ();
            return new Contentresult {Content = jsondata, ContentType = ' Application/json '}}
View Code

Data style screenshot in transmission:

I use and this, the next encounter to write again, thank you. (Please instruct if there is any defect)

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: 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.