Friday 14 February 2014

Get sever site data using jq

public partial class handlerPage : IHttpHandler
    {
        bool IHttpHandler.IsReusable
        {
            get
            {
                return false;
            }
        }

        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            // throw new NotImplementedException();
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string ResultString = string.Empty;
            List<CharEntity> Lst = new List<CharEntity>();
            Lst = GetDataFromList();
            ResultString = js.Serialize(Lst);
            context.Response.Write(ResultString);
        }
    }

 public List<CharEntity> GetDataFromList()
        {
            List<CharEntity> Lst = new List<CharEntity>();
                      for (int x = 0; x <= 2; x++)
                        {
                            Lst.Add(new CharEntity
                            {
                                TaskName = Task[x],
                                TaskValues=val[x]
                            });
                        }
}

 function getChart(val) {
        var ChartData = GetChartData();
}

 function GetChartData() {
        try {
            var Task1 = new Array();

            var url = "/_layouts/15/Igrid_Petronash/handlerPage.ashx";
            var xmlHttp = new XMLHttpRequest();
            xmlHttp.open("POST", url, false);
            xmlHttp.send(null);
            var layerHTML = xmlHttp.responseText;
            var msg1 = JSON.parse(layerHTML);
            return msg1;
}}

Friday 3 January 2014

Get server side data using jq

public partial class handlerPage : IHttpHandler
    {
        bool IHttpHandler.IsReusable
        {
            get
            {
                return false;
            }
        }

        void IHttpHandler.ProcessRequest(HttpContext context)
        {
            // throw new NotImplementedException();
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            string ResultString = string.Empty;
            List<CharEntity> Lst = new List<CharEntity>();
            Lst = GetDataFromList();
            ResultString = js.Serialize(Lst);
            context.Response.Write(ResultString);
        }
    }

 public List<CharEntity> GetDataFromList()
        {
            List<CharEntity> Lst = new List<CharEntity>();
                      for (int x = 0; x <= 2; x++)
                        {
                            Lst.Add(new CharEntity
                            {
                                TaskName = Task[x],
                                TaskValues=val[x]
                            });
                        }
}

 function getChart(val) {
        var ChartData = GetChartData();
}

 function GetChartData() {
        try {
            var Task1 = new Array();

            var url = "/_layouts/15/Igrid_Petronash/handlerPage.ashx";
            var xmlHttp = new XMLHttpRequest();
            xmlHttp.open("POST", url, false);
            xmlHttp.send(null);
            var layerHTML = xmlHttp.responseText;
            var msg1 = JSON.parse(layerHTML);
            return msg1;
}}




Export to Excel after Page is Refresh using C#

<script type="text/javascript" language="javascript">
    //sharepoint postback to work after clicking on export to excel button

    if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' &&
                                           _spBodyOnLoadFunctionNames != null) {
        _spBodyOnLoadFunctionNames.push("supressSubmitWraper");
    }

    function supressSubmitWraper() {

        _spSuppressFormOnSubmitWrapper = true;

    }
</script>