Thursday, April 23, 2015

ASP.NET CheckBoxList Operations with jQuery - Check/Uncheck All Checkboxes

$("[id*=CheckBoxList1] input:checkbox").prop('checked',true); //To check all
$("[id*=CheckBoxList1] input:checkbox").prop('checked',false);// To uncheck all

ASP.NET CheckBoxList Operations with jQuery - Get Text of Selected Items

 $("[id*=CheckBoxList1] input:checked").each(function () {
         alert($(this).next().html());
     });

ASP.NET CheckBoxList Operations with jQuery - Get Index of selected items

 var $ctrls = $("[id*=CheckBoxList1] input:checkbox");
       $("[id*=CheckBoxList1] input:checked").each(function () {
          alert($ctrls.index($(this)));
       }); 

ASP.NET CheckBoxList Operations with jQuery - Get Value of Selected Items

 var selectedValues = [];
    $("[id*=CheckBoxList1] input:checked").each(function () {          
        selectedValues.push($(this).val());
    });
    if (selectedValues.length>0) {
        alert("Selected Value(s): " + selectedValues);
    } else {
        alert("No item has been selected.");
    }

Wednesday, April 22, 2015

angularjs link ng href table

 <td><a ng-href="#/caseinformation/{{item.d}}">{{item.Case}} </a> </td>

Tuesday, April 21, 2015

AngularJs check validation required

<html>
<title> AngularJs Directives </title>
<head>
<title>Angular JS Table</title>
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f2f2f2;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
</style>
</head>
<body>

<div ng-app="myApp">

<div ng-controller="studentController">

<form name="studentForm" novalidate>

<input name="firstname" type="text" ng-model="firstname" required>

<span style="color:red;" ng-show="studentForm.firstname.$error.required"> First Name Is required</span>

<input name="lastname" type="text" ng-model="lastname" required>

<input name="email" type="email" ng-model="email" required>

<button ng-click="reset()">Reset</button>

</form>

</div>


</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="main.js"></script>
<script src="studentController.js"></script>
</body>
</html>

////////////////Main.js///////////////////

var myApp=angular.module("myApp",[]);


////////////studentController//////////


myApp.controller("studentController",function($scope)
{
$scope.reset=function()
{
$scope.firstname='Shekhar',
$scope.lastname='Nawale',
$scope.email='nawale.shekhar1@gmail.com'
};
$scope.reset();
});

AngularJs Validate Data

The following can be used to track error.

 $dirty - states that value has been changed.

 $invalid- states that value entered is invalid.

 $error- states the exact error.