Monday, August 13, 2018

jQuery checkbox OnChange

We can use jQuery to identify checkbox state change as shown below.

<script  type="text/javascript">

 funciton pageLoad() //can use either DOM Ready or pagLoad
{

   const chkSelectAll= $("#chkSelectAll");

   chkSelectAll.change(function(event) {
             var chkBox= event.target;
             if (chkBox.checked) {
               //Checkbox is checked
            } else {
              //Checkbox is unchecked
           }
});

}
</script>
Cheers,
Samitha

Tuesday, July 31, 2018

Get Total Checkboxes using jQuery

Suppose there are several check boxes which are either checked or unchecked. jQury can be used to easily get the number of all check boxes, checked and unchecked boxes as shown below.

var totalCheckboxes = $('input:checkbox').length;
var totalChecked = $('input:checkbox:checked').length;
var totalUnChecked = totalCheckboxes - totalChecked ;

 

Cheers,
Samitha

Thursday, July 26, 2018

jquery Find all elements containing part of an ID

We can use jQuery to find all  elements that starts with of characters as shown below

  $("[id*=_visible_]").each(function(element){
     element.val(''); // do something with the found element.
});

Cheers,
Samitha

Thursday, July 19, 2018

Create an insert script using SELECT

There are many third party tools that provides this feature, but you can use a simple
select statement  easily create an insert script as shown belowe.

Suppose you have employee table  and want to use it to generate data for another table.


select 'insert into Table1 values(' + Id + ', ' + name + ')' from employee


Cheers,
Samitha

Thursday, June 7, 2018

SQL Server drop Unique Key script

While you can uses SSMS to easilly drop a Uniqe key, there may be situaitons where that needs to be done via a script.

Following script can be used to drop a Unique Key on a given column


IF  EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name ='Employee' AND  CONSTRAINT_TYPE='UNIQUE' )
    ALTER TABLE [dbo].[Employee] DROP CONSTRAINT [UC_Employee_emp_code]
GO

Cheers,
Samitha

Friday, April 27, 2018

Programmatically Stop a Windows Service (Vb.Net)


You can easily start/stop a windows service using the following code snippet.


Dim service As ServiceController = New ServiceController("Service Name")
        If (service.Status.Equals(ServiceControllerStatus.Running)) Then
            service.Stop()
        End If



Cheers,
Samitha

Sunday, March 25, 2018

Nuget error while retrieving package metadata

When you try to upgrade an existing Nuget package you have might encountered the following error.

An error occurred while retrieving package metadata for 'bootstrap.3.3.5' from source 'nuget.org'

You can resolve this issue using two steps.

1. Open the packages.config from visual studio editor or notepad. Locate the line related to the corrupted package name and remove it.
2. Clean build the solution.

Cheers,
Samitha