Translate

Wednesday, 27 April 2016

Access WCF service using Jquery Ajax and C#.Net

How to access WCF service Using Jquery ajax and C#.net

For Reference
https://debugmode.net/2011/12/22/how-to-enable-rest-and-soap-both-on-the-same-wcf-service/





<script>
    $(document).ready(function () {
        var URL = "http://sample/service.svc/Check_Session";
        $.ajax({
            type: 'GET',
            url: URL,
            dataType: 'json',
            crossDomain: true,
            success: function (data) {
                if (data.Message != "Success") {
                    alert("success");
                }
                else {
                  
                    alert("Fail");
                }
            },
            error: function (ex) {
                console.log("err");
            }
        });
    });

</script>

Thursday, 21 April 2016

Add proxy class for wcf service through Visual studio Command promt



Open VS command Prompt and  give path of svcutil
 and add service


see the below url for ur reference
http://www.codeproject.com/Articles/786601/Ways-to-generate-proxy-for-WCF-Service

Sunday, 14 February 2016

Encrypt and Decrypt Connectionstring and AppSettings Sections in web.config


Encrypt:

aspnet_regiis.exe -pef "appSettings" "D:\Sample\WebSite1" -prov "DataProtectionConfigurationProvider"


aspnet_regiis.exe -pef "connectionStrings" "D:\Sample\WebSite1" -prov "DataProtectionConfigurationProvider"

Decrypt:

aspnet_regiis.exe -pdf "appSettings" "D:\Sample\WebSite1"


aspnet_regiis.exe -pdf "connectionStrings" "D:\Sample\WebSite1" 

Sunday, 10 January 2016

Access Resource values for db values





 ddlState.Items(index).Value = ds.Tables(0).Rows(index)("Region_Code")
                ddlState.Items(index).Text = GetLocalResourceObject(ds.Tables(0).Rows(index)("Resource_key").ToString() + ".Text").ToString

Monday, 4 January 2016

Jquery Text Easy Counter



Jquery text easy Counter shown below




<h2>EasyCountrer</h2>
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/Content/js/jquery.jqEasyCharCounter.min.js"></script>


<textarea id="easy" ></textarea>
<script>
    $(document).ready(function () {
        $("#easy").jqEasyCounter(
            {
                'maxChars': 160,
                        'maxCharsWarning': 150
            });
    });

</script>

OutPut:



Thursday, 17 December 2015

How to Bind Table Using Angular JS

Bind Table Using Angular JS

View:


<div ng-app="repeatTable" ng-controller="practiece1" id="App4">
        <table >
            <tr >
                <td>Id</td>
                <td>User Name</td>
                <td>First Name</td>
                 <td>Last Name</td>
                 <td>Location</td>
            </tr>
            <tr ng-repeat="data in tabledata" style="border: solid">
                <td>{{data.Id}}</td>
                <td>{{data.UserName}}</td>
                <td>{{data.FirstName}}</td>
                 <td>{{data.LastName}}</td>
                 <td>{{data.Location}}</td>
            </tr>
        </table>

    </div>

<script>
  var aps = angular.module('repeatTable', []).controller('practiece1', function ($scope, $http) {
            alert("");
            $http.get('/AngularJS/TableData').success(function (data) {
                alert(data);
                $scope.tabledata = data;
            });

        });
</script>


In Controller:

    public ActionResult TableData()
        {
            var text = context.UserInfoes.ToList();
            return Json(text,JsonRequestBehavior.AllowGet);
        }


Casacading Dropdowns using Angular JS

 Cascading Dropdown using Angular JS shown below

In view


@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <meta name="viewport" content="width=device-width" />
    <title>AngularJS1</title>
</head>

<div ng-app="myApp" ng-controller="MyCtrl">
    <select data-ng-model="country" data-ng-options="c.CountryId as c.CountryName for c in countries" data-ng-change="GetStates()">
        <option value="">-- Select Country --</option>
    </select>

    <select data-ng-model="state" data-ng-disabled="!states" data-ng-options="s.StateId as s.StateName for s in states">
        <option value="">-- Select State --</option>
    </select>
</div>
</html>
<script>
    var app = angular.module('myApp', []);
    app.controller('MyCtrl', function ($scope, $http) {
        $http({
            method: 'Get',
            url: '/AngularJS/GetCountries'
        }).success(function (data) {
            $scope.countries = data;
        }).error(function (data, status, headers, config) {
            $scope.message = 'Unexpected Error';
        });


        $scope.GetStates = function () {
          
            var countryId = $scope.country;
            alert(countryId);
            if (countryId) {
                $http({
                    method: 'POST',
                    url: '/AngularJS/GetStates/',
                    data: JSON.stringify({ countryId: countryId })
                }).success(function (data) {
                    $scope.states = data;
                }).error(function (data, status, headers, config) {
                    $scope.message = 'Unexpected Error';
                });
            }
            else {
                $scope.states = null;
            }
        }
    })
</script>



In Controller
public ActionResult AngularJS1()
        {
            return View();
        }


        public JsonResult GetCountries()
        {

                var ret = context.Countries.Select(x => new { x.CountryId, x.CountryName }).ToList();
                return Json(ret, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public JsonResult GetStates(int countryId)
        {
                var ret = context.States.Where(x => x.CountryId == countryId).Select(x => new { x.StateId, x.StateName }).ToList();
                return Json(ret);
        }