Popular Posts

Tuesday, January 28, 2014

Wednesday, January 22, 2014

Truthy and falsy jsvascript

http://www.codeproject.com/Articles/713894/Truthy-Vs-Falsy-Values-in-JavaScript

Mustache jquery plug in

http://www.jonnyreeves.co.uk/2012/using-external-templates-with-mustache-js-and-jquery/

Tuesday, January 21, 2014

Custom message based wcf

http://www.codeproject.com/Articles/598157/Building-SOAP-Message-Based-Web-Services-with-WCF

Monday, January 20, 2014

Signalr client code

https://github.com/SignalR/SignalR/tree/master/src/Microsoft.AspNet.SignalR.Client.JS

Saturday, January 11, 2014

Friday, January 3, 2014

Bashing my head to the wall for the last few days as Kendo UI Grid was populating properly but when clicking Delete Or Update button it was always passing NULL to the Controller parameter.

The solution was to build the javascript result manaully before posting so MVC default model binder nows how to deserialise it.

The trick is that the MVC controller parameter should be called as products too:

result["products[" + i + "]." + member]


<script>
        $(document).ready(function () {
            dataSource = new kendo.data.DataSource({
                    transport: {
                        read: {
                            url: "ShoppingCartDetailsRead",
                            dataType: "json"
                        },
                        update: {
                            url: "ShoppingCartDetailsUpdate",
                            dataType: "json",
                            contentType: "application/json",
                            type: "POST"
                        },
                        destroy: {
                            url: "ShoppingCartDetailsDelete",
                            dataType: "json",
                            type: "POST"
                        },
                        parameterMap: function (data, type) {
                            if (type != "read") {
                                
                // post the products so the ASP.NET DefaultModelBinder will understand them:
                                var result = {};
 
                                for (var i = 0; i < data.models.length; i++) {
                                    var product = data.models[i];
 
                                    for (var member in product) {
                                        result["products[" + i + "]." + member] = product[member]; //NB: controller parameter should be products
                                    }
                                }
                                return result;
                                
                            } else {
                                return JSON.stringify(data);
                            }
                        }
                    },
                    batch: true,
                    pageSize: 20,
                    schema: {
                        model: {
                            id: "ShoppingCartItemID",
                            fields: {
                                ShoppingCartItemID :  { editable: falsedefault:1},
                                ShoppingCartID: { editable: false},
                                ProductID: { editable: false},
                                ProductName: { validation: { required: true } },
                                ListPrice: { type: "number"},
                                Quantity: { type: "number"}
                            }
                        }
                    }
                });
 
            $("#grid").kendoGrid({
                dataSource: dataSource,
                navigatable: true,
                sortable: true,
                pageable: true,
                toolbar: ["save""cancel"],
                columns: [
                    { field: "ShoppingCartItemID", title: "Cart Id", width: 30 },
                    { field: "ShoppingCartID", title: "User Id", width: 110 },
                   { field: "ProductName", title: "Item", width: 110 },
                    { field: "ProductId", title: "Item Id", width: 110 },
                    { field: "ListPrice", title: "List Price", format: "{0:c}", width: 110 },
                    { field: "Quantity", title: "Quantity", width: 110 },
                    { command: "destroy", title: "&nbsp;", width: 90 }],
                editable: true
            });
        });
    </script>

Wednesday, January 1, 2014

Ioc vs di plus videos

http://www.codeproject.com/Articles/592372/Dependency-Injection-DI-vs-Inversion-of-Control-IO

Design patterns interview questions

http://www.codeproject.com/Articles/592372/Dependency-Injection-DI-vs-Inversion-of-Control-IO

Uni offering free courses

http://www.codeproject.com/Articles/704567/Learning-Opportunities-online