Friday, February 10, 2012

Ajax MaskEdit For Date Validator.....


  <asp:TextBox ID="txtShipmentDate" runat="server" Width="120px" ValidationGroup="a"></asp:TextBox>    
    <asp:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
        TargetControlID="txtShipmentDate"
        MaskType="Date"
        Mask="99/99/9999"
        MessageValidatorTip="true"
        CultureName="en-US"
        OnFocusCssClass="MaskedEditFocus"
        OnInvalidCssClass="MaskedEditError"
        DisplayMoney="Left"
        AcceptNegative="Left"
        ErrorTooltipEnabled="True" />
    <asp:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
        ControlExtender="MaskedEditExtender1"
        ControlToValidate="txtShipmentDate"
        EmptyValueMessage="Date is required"
        InvalidValueMessage="Date is invalid"
        Display="Dynamic"
        TooltipMessage=""
        EmptyValueBlurredText="*"
        InvalidValueBlurredMessage="*" ForeColor="Red" ValidationGroup="a"/>
<br />
<asp:Button ID="submit" Text="submit" runat="server" ValidationGroup="a"/>

Property Of MaskEdit


  • MaskType - Type of validation to perform:
    None - No validation
    Number - Number validation
    Date - Date validation
    Time - Time validation
    DateTime - Date and time validation
  • Mask Characters and Delimiters
    9 - Only a numeric character
    L - Only a letter
    $ - Only a letter or a space
    C - Only a custom character (case sensitive)
    A - Only a letter or a custom character
    N - Only a numeric or custom character
    ? - Any character

    / - Date separator
    : - Time separator
    . - Decimal separator
    , - Thousand separator
    \ - Escape character
    { - Initial delimiter for repetition of masks
    } - Final delimiter for repetition of masks

    Examples:
    9999999 - Seven numeric characters
    99\/99 - Four numeric characters separated in the middle by a "/"
  • AcceptAMPM - True to display an AM/PM symbol
  • AcceptNegative - True if the negative sign (-) is allowed
    None - Do not show the negative sign
    Left - Show the negative sign on the left of the mask
    Right - Show the negative sign on the right of the mask
  • AutoComplete - True to automatically fill in empty mask characters not specified by the user
    MaskType=Number - Empty mask characters will be filled with zeros
    MaskType=Time - Empty mask characters will be filled with the current time
    MaskType=Date - Empty mask characters will be filled with the current date
    MaskType=DateTime - Empty mask characters will be filled with the current date/time
  • AutoCompleteValue - Default character to use when AutoComplete is enabled
  • Century - Default century used when a date mask only has two digits for the year
  • ClearMaskOnLostFocus - True to remove the mask when the TextBox loses focus
  • ClearTextOnInvalid - True to clear the TextBox when invalid text is entered
  • ClipboardEnabled- True to allow copy/paste with the clipboard
  • ClipboardText - Prompt text to use when a clipboard paste is performed
  • DisplayMoney - Specifies how the currency symbol is displayed
    None - Do not show the currency symbol
    Left - Show the currency symbol on the left of the mask
    Right - Show the currency symbol on the right of the mask
  • ErrorTooltipCssClass - CSS class for the tooltip message
  • ErrorTooltipEnabled - True to show a tooltip message when the mouse hovers over an invalid TextBox
  • Filtered - Valid characters for mask type "C" (case-sensitive)
  • InputDirection - Text input direction
    LeftToRight - Left to Right
    RightToLeft - Right to left
  • MessageValidatorTip - Message displayed when editing in TextBox
  • PromptChararacter - Prompt character for unspecified mask characters
  • UserDateFormat - Custom date format
  • UserTimeFormat - Custom time format
  • OnFocusCssClass - CSS class used when the TextBox receives focus
  • OnFocusCssNegative - CSS class used when the TextBox gets focus with a negative value
  • OnBlurCssNegative - CSS class used when the TextBox loses focus with a negative value
  • OnInvalidCssClass - CSS class used when the text is not valid.
  • CultureName - Name of culture to use (overrides the default page culture)
  • CultureAMPMPlaceholder - Culture override
  • CultureCurrencySymbolPlaceholder - Culture override
  • CultureDateFormat - Culture override
  • CultureDatePlaceholder - Culture override
  • CultureDecimalPlaceholder - Culture override
  • CultureThousandsPlaceholder - Culture override
  • CultureTimePlaceholder - Culture override

Thursday, February 2, 2012

What is DENSE_RANK(),Rank(),ROW_NUMBER in Sql?


-> Create a Table BlogCount

CREATE TABLE [dbo].[BlogCount](
[BloggerName] [varchar](10) NULL,
[Topic] [varchar](15) NULL,
[Year] [int] NULL,
[Total] [int] NULL
)

->Inserting Data

INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Ritesh', N'SQL', 2006, 17)
INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Ritesh', N'SQL', 2007, 124)
INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Ritesh', N'SQL', 2008, 124)
INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Ritesh', N'.NET', 2008, 24)
INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Alka', N'SQL', 2007, 14)
INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Alka', N'.NET', 2007, 18)
INSERT [dbo].[BlogCount] ([BloggerName], [Topic], [Year], [Total]) VALUES (N'Alka', N'SQL', 2008, 14)


->Now write a Querry.

Select * from BlogCount

->This will show you all the data.

BloggerName         Topic       Year         Total
Ritesh        SQL 2006 17
Ritesh        SQL 2007 124
Ritesh        SQL 2008 124
Ritesh        .NET 2008 24
Alka SQL 2007 14
Alka .NET 2007 18
Alka SQL 2008 14

->Now Lets Apply the DENSE_RANK and Partition in Querry.

SELECT BloggerName,Topic,[Year],Total,DENSE_RANK()  OVER (Partition by BloggerName Order by Total DESC) as 'Ranking'
FROM
BlogCount

BloggerName     Topic     Year       Total Ranking
Alka .NET 2007 18 1
Alka SQL 2008 14 2
Alka SQL 2007 14 2
Ritesh        SQL 2007 124 1
Ritesh        SQL 2008 124 1
Ritesh    .Net 2008 24 2
Ritesh    SQL 2006 17 3

->Now Lets Apply RANK instead of DENSE_RANK.

SELECT BloggerName,Topic,[Year],Total,RANK()  OVER (Partition by BloggerName Order by Total DESC) as 'Ranking' FROM BlogCount

BloggerName     Topic     Year       Total Ranking
Alka .NET 2007 18 1
Alka SQL 2008 14 2
Alka SQL 2007 14 2
Ritesh        SQL 2007 124 1
Ritesh        SQL 2008 124 1
Ritesh    .Net 2008 24 3
Ritesh    SQL 2006 17 4

->From Above Two Querry what is the difference between Two DENSE_RANK and RANK?
  In Rank() function if there is two same Rank  then the next rank will be not immediate after the same rank but its number of that record..for example if there are two records of the same Rank say 1 then the next rank will be the 3 and so on.while in DENSE_RANK it will be next rank.means if there are two record of Rank 1 then the next rank will be the 2.Just check the above two examples and see the output you will get clear Idea.


ROW_NUMBER:It will Return the RowNumber.

Select * from BlogCount

BloggerName         Topic       Year         Total
Ritesh        SQL 2006 17
Ritesh        SQL 2007 124
Ritesh        SQL 2008 124
Ritesh        .NET 2008 24
Alka SQL 2007 14
Alka .NET 2007 18
Alka SQL 2008 14

SELECT ROW_NUMBER() OVER (
   ORDER BY Total) AS RowNumber,
BloggerName, Topic,[Year],Total
FROM BlogCount


Output

RowNumber BloggerName     Topic     Year       Total
1 Alka SQL 2007 14
2 Alka SQL 2008 14
3 Ritesh        SQL 2006 14
4 Alka .Net 2007 18
5 Ritesh        .Net 2008 24
6 Ritesh    SQL 2007 124
7 Ritesh    SQL 2008 124