Monday, July 28, 2014

using JQuery to detect the textbox change from the client side in ASP.Net web application

for javascript we can handle the textbox change event with onChange attribute from control

but the onChange only fire when the control lost the focus. so you might even need to implement the
OnKeyUp event if you want to handle the content change in the textbox.


However JQuery will simplify the process by bundling those events together(onChange, OnKeyUp, OnKeyDown).

the following is an example to handle auto tab when the length of content had reached the max length in the text box. the text box control will lost it focus and cursor will move to the next control in the tab order.


if($(".MyControlCSS") !=null){
                $(".MyControlCSS").on("input",function(e){
                   //put your logic here to manipulate the content change
                    SetAutoTab("MyControlCSS","NextControlCSS",3)   
                })
            }

function SetAutoTab(MyControlCSS,NextControlCSS, maxLength){
    var myControl=$('.' +MyControlCSS);
    if(myControl !=null){
         if(myControl .val().length==maxLength){
            $('.'+NextControlCSS).focus();
        }
    }
}


Wednesday, July 23, 2014

How to quickly identify the change in the SQL Server

Recently i need to do an enhancement on the current existing application. My manager ask me to provide him a list of the change on the SQL Server in the staging environment.

It is very challenge to review every table, stored procedure and view to compare the change

here is a handy script to see the change of View in the last two week.

SELECT Name
FROM sys.objects
WHERE type = 'V'
AND DATEDIFF(D,Modify_Date, GETDATE()) < 14

To get the change of Stored Procedure

SELECT Name
FROM sys.objects
WHERE type = 'P'
AND DATEDIFF(D,Modify_Date, GETDATE()) < 14

To get change of User Table

SELECT Name
FROM sys.objects
WHERE type = 'U'
AND DATEDIFF(D,Modify_Date, GETDATE()) < 14


You can get the following types from MSDN

 sys.objects (Transact-SQL)

AF = Aggregate function (CLR)
C = CHECK constraint
D = DEFAULT (constraint or stand-alone)
F = FOREIGN KEY constraint
FN = SQL scalar function
FS = Assembly (CLR) scalar-function
FT = Assembly (CLR) table-valued function
IF = SQL inline table-valued function
IT = Internal table
P = SQL Stored Procedure
PC = Assembly (CLR) stored-procedure
PG = Plan guide
PK = PRIMARY KEY constraint
R = Rule (old-style, stand-alone)
RF = Replication-filter-procedure
S = System base table
SN = Synonym
SO = Sequence object
Applies to: SQL Server 2012 through SQL Server 2014.
SQ = Service queue
TA = Assembly (CLR) DML trigger
TF = SQL table-valued-function
TR = SQL DML trigger
TT = Table type
U = Table (user-defined)
UQ = UNIQUE constraint
V = View
X = Extended stored procedure