Wednesday, April 8, 2015

Select Dropdown option in jquery

CaseId=0; or
CaseId=1;or
CaseId=2; or
CaseId=3;
$('#ddl').val(CaseId);

sql get current date

Use GETDATE() function

Update Table_Name
set column= GETDATE()
where id = 1;

SQL UPDATE Syntax

UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;

Why to choose Asp.Net Web API ?

  1. If we need a Web Service and don’t need SOAP, then ASP.Net Web API is best choice.
  2. It is Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.
  3. It doesn't have tedious and extensive configuration like WCF REST service.
  4. Simple service creation with Web API. With WCF REST Services, service creation is difficult.
  5. It is only based on HTTP and easy to define, expose and consume in a REST-ful way.
  6. It is light weight architecture and good for devices which have limited bandwidth like smart phones.
  7. It is open source.

Thursday, March 12, 2015

AngularJs set limit to decimal places

app.filter('setDecimal', function ($filter) {
    return function (input, places) {
        if (isNaN(input)) return input;
        // If we want 1 decimal place, we want to mult/div by 10
        // If we want 2 decimal places, we want to mult/div by 100, etc
        // So use the following to create that factor
        var factor = "1" + Array(+(places > 0 && places + 1)).join("0");
        return Math.round(input * factor) / factor;
    };
});

Wednesday, March 11, 2015

C# program that uses abstract class

using System;

abstract class Test
{
    public int _a;
    public abstract void A();
}

class Example1 : Test
{
    public override void A()
    {
 Console.WriteLine("Example1.A");
 base._a++;
    }
}

class Example2 : Test
{
    public override void A()
    {
 Console.WriteLine("Example2.A");
 base._a--;
    }
}

class Program
{
    static void Main()
    {
 // Reference Example1 through Test type.
 Test test1 = new Example1();
 test1.A();

 // Reference Example2 through Test type.
 Test test2 = new Example2();
 test2.A();
    }
}

Output

Example1.A
Example2.A