Friday, 20 July 2012

regular expression validator in asp.net

Follow the link everything is working fine

http://msdn.microsoft.com/en-us/library/ff650303.aspx

regular expression validator in asp.net for phone number

Here the example

<asp:TextBox ID="Phone1" runat="server" Width="90%" Height="30px"></asp:TextBox>

 <asp:RegularExpressionValidator ID="RegularExpressionValidator16" runat="server" ControlToValidate="Phone1"  Display="Dynamic"                                          ValidationExpression="^[+]?\d{9,12}$" ErrorMessage="Invalid"></asp:RegularExpressionValidator>

Thursday, 5 July 2012

Get value from datakeys in gridview

Simple method to get value from datakeys in gridview


LinkButton lb = (LinkButton)e.CommandSource;
GridViewRow gvr = (GridViewRow)lb.NamingContainer;
int id = (int)grid.DataKeys[gvr.RowIndex].Value;

open new window in anchor tag with scroll bar

<a href="#" style="color:White; text-decoration:none;" onclick="javascript:window.open('#','mywindow','width=960,height=700,scrollbars=yes')">Group Article</a>

Friday, 29 June 2012

Validate Words in C#


Text==>u r input Value,,,,,Lenth==>Lenth of words to be check    
 public int ValidateWords(string Text, int Length)
        {
            int result = 0;
            bool lastWasSpace = false;

            foreach (char c in Text)
            {
                if (char.IsWhiteSpace(c))
                {
                    if (lastWasSpace == false)
                    {
                        result++;
                    }
                    lastWasSpace = true;
                }
                else
                {
                    // Count other characters every time.
                    //result++;
                    lastWasSpace = false;
                }
            }

            if (result <= Length && result > 0)
            {
                return 1;
            }
            else if (result > Length)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

Validate Character in C#


Test-->u r input value,, Lenth---->no of character to validate

     public int ValidateLength(string Text, int Length)
        {
            if (Text.Length <= Length && Text.Length > 0)
            {
                return 1;
            }
            else if (Text.Length > Length)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

how Get No of StoredProcedure name and count in sqlserver


To Get No of StoredProcedure name and count in sqlserver


USE DBNAME

SELECT * From SYS.PROCEDURES