Thursday, August 27, 2015

Telerik kendo ui grid - How to pass data from page to api service

<div style="width: 99%; margin-left: 6px; margin-right: 6px;">
                                    <div id="example">
                                        <div id="grid"></div>
                                    </div>
                                </div>





$(document).ready(function () {

            var APIbaseUrl = '<%=this.APIbaseUrl%>';

            var models = {};
            var expenseWorkflowInfo = {
                models: {
                    ExpenseId: 1
                }
            };

            var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: APIbaseUrl + "/User/Product",
                        dataType: "json",
                        type: "POST",
                        data: expenseWorkflowInfo
                    },
                    update: {
                        url: APIbaseUrl + "/User/Product",
                        dataType: "json",
                        type: "POST",
                        data: expenseWorkflowInfo
                    },
                    destroy: {
                        url: APIbaseUrl + "/User/Product",
                        dataType: "json",
                        type: "POST",
                        data: expenseWorkflowInfo
                    },
                    create: {
                        url: APIbaseUrl + "/User/Product",
                        dataType: "json",
                        type: "POST",
                        data: expenseWorkflowInfo
                    },
                    parameterMap: function (options, operation) {
                        debugger;
                        if (operation !== "read" && options.models[0]) {
                            return options.models[0];
                        }
                        else if (operation == "read" && options.models) {
                            return options.models;
                        }

                    }
                },
                batch: true,
                pageSize: 5,
                schema: {
                    model: {
                        id: "ExpenseId",
                        fields: {
                            ExpenseId: { editable: false, nullable: true },
                            Subject: { validation: { required: true } }//,
                            //BranchId: { type: "number", validation: { required: true } },
                            //LeadId: { type: "number", validation: { required: true } }
                        }
                    }
                }
            });

            $("#grid").kendoGrid({
                dataSource: dataSource,
                pageable: true,
                height: 550,
                toolbar: ["create"],
                columns: [
                    "Subject",
                    //{ field: "BranchId", title: "Branch Id", format: "{0:c}", width: "120px" },
                    //{ field: "LeadId", title: "Lead Id", width: "120px" },
                    { command: ["edit", "destroy"], title: "&nbsp;", width: "250px" }],
                editable: "inline"
            });

        });

Tuesday, August 18, 2015

Call parent Javascript function from inside an iframe

window.parent.rxTreeSelectNode(folderID);

rxTreeSelectNode - Your Function Name

Iframe set source or href using jquery

    var folderID = $(this).closest('[id]').attr('id');
                var url = 'UploadMultipleFiles.aspx?folderId=' + folderID;
                $('#myframe').attr("src", url);

asp.net access c# variable in javascript

1)  asp.net code behind
 public partial class UploadMultipleFiles : System.Web.UI.Page
    {
        public string eCabinetbaseURL = Functions.ToString(ConfigurationManager.AppSettings["eCabinetServiceUrl"]);

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }

2)  In Javascript function

 var eCabinetServiceUrl = '<%=eCabinetbaseURL%>';


Jquery get session value asp.net

var sessionId = '<%=HttpContext.Current.Session["SessionID"]%>';

jquery get Url parameters

function getParameterByName(name) {
            name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
                results = regex.exec(location.search);
            return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        }

Tuesday, August 4, 2015

Could not load file or assembly System.Net.Http.Primitives. Located assembly's manifest definition does not match the assembly reference

Add


 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.29.0" newVersion="4.2.29.0" />
</dependentAssembly>
</assemblyBinding>


Remove <assemblyBinding  appliesTo="v.02" attribute

if attribute present it search for system.primitive dll with version 1.5. which is not present
else it loads System.Net.Http.Primitives with 4.2.29.0

Don't touch machine.config because its a heart of system server.
Doctor never opens patient's heart for chest pain.