Delegate

delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method. The delegate method can be used like any other method, with parameters and a return value

Delegates have the following properties:
  • Delegates are similar to C++ function pointers, but are type safe.
  • Delegates allow methods to be passed as parameters.
  • Delegates can be used to define callback methods.
  • Delegates can be chained together; for example, multiple methods can be called on a single event.

Turn On Visual Studio 2005/2008/2010 Line Numbering

Visual Studio Line Numbering Setting


 

 Text Editor Settings

Once all of the settings are visible, expand the Text Editor branch of the tree. Here you can see a list of all of the languages for which settings may be modified. We will enable line numbering for C# code editing. Expand the C# node of the tree and select the General section to reveal the settings. To enable source code line numbering, tick the appropriate checkbox. Click OK to accept the setting and the line numbers will appear.


Find number of days in a given month



This user defined functions return the number of days in a given month.
ALTER FUNCTION GetDaysCountInMonth( @Date DATETIME )
RETURNS INT
AS
BEGIN
      DECLARE @count INT
      SET @count = CASE
      WHEN DATEPART(MM,@Date) IN (1, 3, 5, 7, 8, 10, 12) THEN 31
      WHEN DATEPART(MM,@Date) IN (4, 6, 9, 11) THEN 30
      ELSE
            CASE WHEN (DATEPART(YY,@Date) % 4 = 0
            AND
            DATEPART(YY,@Date) % 100 != 0)
            OR
            ((DATEPART(YY,@Date)) % 400 = 0)
            THEN 29
      ELSE 28
END
END
RETURN @count
END
GO

--Result
SELECT dbo.GetDaysCountInMonth(GETDATE()) COUNT
SELECT dbo.GetDaysCountInMonth('2000-02-12') COUNT--Leap year
SELECT dbo.GetDaysCountInMonth('2100-02-12') COUNT


How to Show / Hide a ModalPopupExtender using Javascript


If we have a ModalPopupExtender with the id ‘modPopup_ModalPopupExtender’, and need to display or hide it in javascript, we can easily do this using the $find() function.
Let’s see this in action:

ASPX :


JAVA SCRIPT: