.

angular.modules

(function () {
    var orig = angular.module;
    angular.modules = [];
    angular.module = function () {
        var args = Array.prototype.slice.call(arguments);
        if (arguments.length > 1) {
            angular.modules.push(arguments[0]);
        }
        return orig.apply(null, args);
    }
})();

//usage:  angular.modules

json and xml to c#

http://json2csharp.com/#

http://jsonutils.com/

 

Hello World of AngularJS

This is the simplest test to see if AngularJS is working correctly.

<script src="http://code.angularjs.org/1.0.5/angular.js"></script>

<div ng-app>
    Name: <input type=text ng-model="name">
    <br>
    Current user's name: {{name}}
</div>

and the following is a script test call:

<script language="javascript">
    if (typeof angular == 'undefined') {
        alert('AngularJS not available');
    }
</script>

Angular JS simplified

angular-demo

https://www.youtube.com/watch?v=i9MHigUZKEM

 

using System.Json for dynamic json

open your package manager console and type:

Install-Package System.Json -Version 4.0.20126.16343

add the reference to your code:

using System.Json;

and finally example usage:

var json = GetJson(input);
dynamic result = JsonValue.Parse(json);

Custom Json

This is how you can write out your own custom Json code in MVC:

public ActionResult hello()
{
    dynamic d = new JObject();
    d.MetricId = 11;
    string json = Newtonsoft.Json.JsonConvert.SerializeObject(d);
    return Content(json,"JSon");
}

AllowGet JsonRequestBehavior

Getting the following error:
This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

Try to add “JsonRequestBehavior.AllowGet” to your return statement.

public JsonResult GetJsonData()
{
    MetricValue m = new MetricValue();
    m.Error = "234";
    m.SnapshotId = 4;
    return Json(m, JsonRequestBehavior.AllowGet);
}

now my output is:

{"MetricId":0,"SnapshotId":4,"Error":"234","Value":null}

 

Loading a web page using json data

sdf

function UpdateOnClick(param123) {
    $.ajax({
        type: 'GET',
        url: "/WhereEver/PageToLoad",
        cache: false,
        data: { myKey: myValue },
        dataType: "json",
        async: true,
        success: function (result) {
            $('#Id1').html(result.ValueX);
            $('#Id2').html(result.ValueY);
        },
        error: function (result) {

        }
    });
}

Quick direct references to Jquery & JqueryU

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>

jQuery.UI available test

<script>
    $(document).ready(function() {
        if (jQuery.ui) {
            alert('jQuery.ui is loaded');

        } else {
            alert('WARNING:  jQuery.ui is NOT loaded!!');
        }
    });
</script>