Powered By Blogger

Monday, November 30, 2009

performance improvement

For better performance improvement..kindly flow the following YSLOW rules,

Performance Improving Methods( From YSlow)
1. Make fewer HTTP requests

Decreasing the number of components on a page reduces the number of HTTP requests required to render the page, resulting in faster page loads. Some ways to reduce the number of components include: combine files, combine multiple scripts into one script, combine multiple CSS files into one style sheet, and use CSS Sprites and image maps.
2. Content Delivery Network (CDN)

User proximity to web servers impacts response times. Deploying content across multiple geographically dispersed servers helps users perceive that pages are loading faster.
3. Add Expires headers

Web pages are becoming increasingly complex with more scripts, style sheets, images, and Flash on them. A first-time visit to a page may require several HTTP requests to load all the components. By using Expires headers these components become cacheable, which avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often associated with images, but they can and should be used on all page components including scripts, style sheets, and Flash.
4. Compress components with gzip

Compression reduces response times by reducing the size of the HTTP response. Gzip is the most popular and effective compression method currently available and generally reduces the response size by about 70%. Approximately 90% of today's Internet traffic travels through browsers that claim to support gzip.

5. Grade A on Put CSS at top

Moving style sheets to the document HEAD element helps pages appear to load quicker since this allows pages to render progressively.
6. Put JavaScript at bottom

JavaScript scripts block parallel downloads; that is, when a script is downloading, the browser will not start any other downloads. To help the page load faster, move scripts to the bottom of the page if they are deferrable.
7. Avoid CSS expressions

CSS expressions (supported in IE beginning with Version 5) are a powerful, and dangerous, way to dynamically set CSS properties. These expressions are evaluated frequently: when the page is rendered and resized, when the page is scrolled, and even when the user moves the mouse over the page. These frequent evaluations degrade the user experience.
8. Make JavaScript and CSS external

Using external JavaScript and CSS files generally produces faster pages because the files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded each time the HTML document is requested. This reduces the number of HTTP requests but increases the HTML document size. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the HTML document size is reduced without increasing the number of HTTP requests.
9. Reduce DNS lookups

The Domain Name System (DNS) maps hostnames to IP addresses, just like phonebooks map people's names to their phone numbers. When you type URL www.yahoo.com into the browser, the browser contacts a DNS resolver that returns the server's IP address. DNS has a cost; typically it takes 20 to 120 milliseconds for it to look up the IP address for a hostname. The browser cannot download anything from the host until the lookup completes.
10. Minify JavaScript and CSS

Minification removes unnecessary characters from a file to reduce its size, thereby improving load times. When a file is minified, comments and unneeded white space characters (space, newline, and tab) are removed. This improves response time since the size of the download files is reduced.
11. Avoid URL redirects

URL redirects are made using HTTP status codes 301 and 302. They tell the browser to go to another location. Inserting a redirect between the user and the final HTML document delays everything on the page since nothing on the page can be rendered and no components can be downloaded until the HTML document arrives.
12.Remove duplicate JavaScript and CSS

Duplicate JavaScript and CSS files hurt performance by creating unnecessary HTTP requests (IE only) and wasted JavaScript execution (IE and Firefox). In IE, if an external script is included twice and is not cacheable, it generates two HTTP requests during page loading. Even if the script is cacheable, extra HTTP requests occur when the user reloads the page. In both IE and Firefox, duplicate JavaScript scripts cause wasted time evaluating the same scripts more than once. This redundant script execution happens regardless of whether the script is cacheable.
12. Configure entity tags (ETags)

Entity tags (ETags) are a mechanism web servers and the browser use to determine whether a component in the browser's cache matches one on the origin server. Since ETags are typically constructed using attributes that make them unique to a specific server hosting a site, the tags will not match when a browser gets the original component from one server and later tries to validate that component on a different server.
13. Make AJAX cacheable

One of AJAX's benefits is it provides instantaneous feedback to the user because it requests information asynchronously from the backend web server. However, using AJAX does not guarantee the user will not wait for the asynchronous JavaScript and XML responses to return. Optimizing AJAX responses is important to improve performance, and making the responses cacheable is the best way to optimize them.
14. GET for AJAX requests

When using the XMLHttpRequest object, the browser implements POST in two steps: (1) send the headers, and (2) send the data. It is better to use GET instead of POST since GET sends the headers and the data together (unless there are many cookies). IE's maximum URL length is 2 KB, so if you are sending more than this amount of data you may not be able to use GET.
15. Reduce the number of DOM elements



A complex page means more bytes to download, and it also means slower DOM access in JavaScript. Reduce the number of DOM elements on the page to improve performance.
16. Avoid HTTP 404 (Not Found) error

Making an HTTP request and receiving a 404 (Not Found) error is expensive and degrades the user experience. Some sites have helpful 404 messages (for example, "Did you mean ...?"), which may assist the user, but server resources are still wasted.
17. Reduce cookie size

HTTP cookies are used for authentication, personalization, and other purposes. Cookie information is exchanged in the HTTP headers between web servers and the browser, so keeping the cookie size small minimizes the impact on response time.
18. Use cookie-free domains

When the browser requests a static image and sends cookies with the request, the server ignores the cookies. These cookies are unnecessary network traffic. To workaround this problem, make sure that static components are requested with cookie-free requests by creating a subdomain and hosting them there.




19. Avoid AlphaImageLoader filter

The IE-proprietary AlphaImageLoader filter attempts to fix a problem with semi-transparent true color PNG files in IE versions less than Version 7. However, this filter blocks rendering and freezes the browser while the image is being downloaded. Additionally, it increases memory consumption. The problem is further multiplied because it is applied per element, not per image.
20. Do not scale images in HTML

Web page designers sometimes set image dimensions by using the width and height attributes of the HTML image element. Avoid doing this since it can result in images being larger than needed. For example, if your page requires image myimg.jpg which has dimensions 240x720 but displays it with dimensions 120x360 using the width and height attributes, then the browser will download an image that is larger than necessary.
21. Make favicon small and cacheable

A favicon is an icon associated with a web page; this icon resides in the favicon.ico file in the server's root. Since the browser requests this file, it needs to be present; if it is missing, the browser returns a 404 error (see "Avoid HTTP 404 (Not Found) error" above). Since favicon.ico resides in the server's root, each time the browser requests this file, the cookies for the server's root are sent. Making the favicon small and reducing the cookie size for the server's root cookies improves performance for retrieving the favicon. Making favicon.ico cacheable avoids frequent requests for it.

Thursday, November 26, 2009

Tips

C# Classes are reference types; they are allocated on the Managed Heap. The Managed Heap is an area of memory that is managed by the Common Language Runtime, which has the ability to free unused memory blocks (objects) in a process known as Garbage Collection.

Access Modifier keywords: public, private, protected and internal.

Class members: fields, properties, methods, constructors, destructor, indexers, constants, events, delegates and operators.

Struct: Similar to Class, A struct type is a value type that can contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types. By default it is sealed. There is no inheritance for structs as there is for classes. The struct type is suitable for representing lightweight objects such as Point, Rectangle, and Color.

class Program

{

struct Simple

{ public int Position;

public bool Exists;

public double LastValue;

};

static void Main ()

{

Simple s;

s.Position = 1;

s.Exists = false;

s.LastValue = 5.5;

}

}

Static class: a static class cannot be instantiated. In other words, you cannot use the new keyword to create a variable of the class type. Ex: UtilityClass.MethodA ();

* Contains only static members. * Cannot be instantiated. * Is sealed. * Cannot contain Instance Constructors.

Static member: A non-static class can contain static methods, fields, properties, or events. The static member is callable on a class even when no instance of the class has been created. The static member is always accessed by the class name, not the instance name. Only one copy of a static member exists, regardless of how many instances of the class are created. Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it is explicitly passed in a method parameter. We can’t use this keyword to access Static Members.

Abstract Class: -cannot be instantiated. - An abstract class is only to be sub-classedinherit only one abstract class, but may implement multiple numbers of Interfaces. - Abstract class methods may OR may not have an implementation. (inherited from). - A class may

An Interface contains only the signatures of methods, properties, events or indexers. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition.

Ex:

Interface ISampleInterface

{ Void SampleMethod (); }

Class ImplementationClass: ISampleInterface

{ // Explicit interface member implementation:

Void ISampleInterface.SampleMethod ()

{ // Method implementation. }

Static void Main ()

{ ISampleInterface obj = new ImplementationClass ();

Obj. SampleMethod (); }

}

Abstract and Virtual Method:

When a base class declares a method as virtual, a derived class can override the method with its own implementation.

If a base class declares a member as abstract, that method must be overridden in any non-abstract class that directly inherits from that class.

Sealed class: A sealed class cannot be used as a base class; it cannot also be an abstract class. By creating an instance we can use the methods in the Sealed Class.

Delegates: Delegates are used to pass methods as arguments to other methods. It allow programmer to encapsulate a reference to a method inside a delegate object.

public delegate void SimpleDeleg();

class DelegateExample

{

public void SimpMet()

{

string s= "I am From Simple Method.";

}

public static void main()

{

SimpleDeleg del = new SimpleDeleg(SimpMet);

SimpleDeleg();

}

}

Value type variables directly contain their values, which mean that the memory is allocated inline in whatever context the variable is declared.

There are two categories of value types: struct and enum.

A type that is defined as a class, delegate, array, or interface is a Reference type. At run time, when you declare a variable of a reference type, the variable contains the value null until you explicitly create an instance of the object by using the new operator

A Generic type can be declared with one or more type parameters. Generic collection classes are called strongly-typed collections because the compiler knows the specific type of the collection's elements and can raise an error at compile-time if, for example, you try to add an integer to the strings object.

Namespaces: .NET Framework uses namespaces to organize its many classes. Namespaces are used to logically arrange classes, structs, interfaces, enum and delegates. One namespace can contain other namespaces also.

The enum keyword is used to declare an enumeration (a numbered list), a distinct type consisting of a set of named constants called the enumerator list.

enum Days {low, medium, high};

class EnumSwitch

{

Public Static Void Main ()

{

Volume myVolume = Volume. Medium;

switch (myVolume)

{

case Volume. Low:

Console.WriteLine("The volume has been turned Down.");

break;

case Volume. Medium:

Console.WriteLine ("The volume is in the middle.");

break;

Case Volume. High:

Console.WriteLine ("The volume has been turned up.");

break;

}

Console.ReadLine ();

}

}

Dictionary: A Dictionary (TKey, TValue) contains a collection of key/value pairs. Its Add method takes two parameters, one for the key and one for the value.

Dictionary students = new Dictionary()

{

{111, new StudentName {FirstName="Sachin", LastName="Karnik", ID=211}},

{112, new StudentName {FirstName="Dina", LastName="Salimzianova", ID=317}},

{113, new StudentName {FirstName="Andy", LastName="Ruth", ID=198}}

};

Boxing: Conversion of Value Types to Reference Types.

Ex: int32 x=10;

Object obj=x; //Implicit Boxing; No need to tell the compiler about boxing

Object obj= (Object) x; //Explicit Boxing;

Unboxing: Conversion of Reference Types to Value Types.

X= obj; //Implicit Unboxing

Constructors: Constructors are class methods that are executed when an object of a given type is created. Constructors have the same name as the class. They do not have return types, not even void. Constructor is invoked by the new operator immediately after memory is allocated for the new object.

A constructor that takes no parameters is called a default constructor. Default constructors are invoked whenever an object is instantiated using the new operator and no arguments are provided to new.

Constructors for struct types are similar to class constructors, but structs cannot contain an explicit default constructor because one is provided automatically by the compiler.

Note: There is always at least one constructor in every class. If you do not write a constructor, C# automatically provides one for you, this is called default constructor.

Destructor: A destructor is just opposite to constructor. It has same as the class name, but with prefix ~ (tilde). They do not have return types, not even void and therefore they cannot return values. Destructor is invoked whenever an object is about to be garbage collected

Finalize () Method of Object class

Each class in C# is automatically (implicitly) inherited from the Object class which contains a method Finalize (). This method is guaranteed to be called when your object is garbage collected (removed from memory). You can override this method and put here code for freeing resources that you reserved when using the object.

Method Overloading: Method with same name but with different arguments is called method overloading. Method Overloading forms compile-time polymorphism.

Class A1

{

Void hello ()

{Console.WriteLine (“Hello”) ;}

Void hello (string s)

{Console.WriteLine (“Hello {0}”, s) ;}

}

Method Overriding: Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its superclass. Method overriding forms Run-time polymorphism.

Note: By default functions are not virtual in C# and so you need to write “virtual” explicitly. While by default in Java each function are virtual.

Class parent

{ Virtual void hello ()

{ Console.WriteLine (“Hello from Parent”) ;}

}

Class child: parent

{ Override void hello ()

{ Console.WriteLine (“Hello from Child”) ;}

}

Static void main ()

{ Parent objParent = new child ();

objParent.hello ();

}

//Output

Hello from Child.

OOPS:

Polymorphism (Many Shapes): Polymorphism is briefly described as "one interface, many implementations. Polymorphism is a characteristic of being able to assign a different meaning or usage to something in different contexts.

There are two types of polymorphism one is compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is functions and operators overloading. Runtime time polymorphism is done using inheritance and virtual functions.

Function Overloading: In case of compile time it is called function overloading. Two or more functions can have same name: different parameters or their data types. Compiler will select the right function depending on the type of parameters passed.

Operator Overloading: Operators can be overloaded in order to perform special functions with respect to the class. With the help of operator overloading standard operations such as +, - , *, etc can be applied on the objects of the class.

Encapsulation is the procedure of covering up of data and functions into a single unit. Ex: Delegate.

Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. Inheritance is the mechanism which allows a class A to inherit properties of a class B.

Note: A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members. Note: Struct is implicitly sealed; so they cannot be inherited.

Wednesday, November 25, 2009

Inheritance and Polymorphism

Inheritance:

Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class.

Conceptually, a derived class is a specialization of the base class. For example, if you have a base class Animal, you might have one derived class that is named Mammal and another derived class that is named Reptile. A Mammal is an Animal, and a Reptile is an Animal, but each derived class represents different specializations of the base class.

  • When you define a class to derive from another class, the derived class implicitly gains all the members of the base class, except for its constructors and destructors.
  • The derived class can thereby reuse the code in the base class without having to re-implement it.
  • In the derived class, you can add more members. In this manner, the derived class extends the functionality of the base class.

C# supports two types of Inheritance mechanisms:

1) Implementation Inheritance
2) Interface Inheritance

Implementation Inheritance:

- When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance

Interface Inheritance:

- When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance

In general Classes can be derived from another class, hence support Implementation inheritance At the same time Classes can also be derived from one or more interfaces Hence they support Interface inheritance Structs can derive from one more interface, hence support Interface Inheritance Structs cannot be derivedfrom another class they are always derived from SystemValueType

Multiple Inheritance:

C# does not support multiple implementation inheritance A class cannot be derived from more than one class However, a class can be derived from Multiple Interfaces.

------------------------------------

Inheritance Syntax:

Class derivedClass:baseClass
{
}


Interface Inheritance:

private Class derivedClass:baseClass , InterfaceX , InterfaceY
{
}

Abstract And Virtual Method:

When a base class declares a method as virtual, a derived class can override the method with its own implementation.

class baseClass
{
public virtual int fnCount()
{
return 10;
}
}

class derivedClass :baseClass
{
public override int fnCount()
{
return 100;
}
}

If a base class declares a member as abstract, that method must be overridden in any non-abstract class that directly inherits from that class.

If a derived class is itself abstract, then it inherit abstract members without implementing them.

Abstract and virtual members are the basis for polymorphism, which is the second primary characteristic of object-oriented programming.


Polymorphism:

Polymorphism is often referred to as the third pillar of object-oriented programming, after encapsulation and inheritance.

  • At run time, objects of a derived class may be treated as objects of a base class in places such as method parameters and collections or arrays. When this occurs, the object's declared type is no longer identical to its run-time type.
  • Base classes may define and implement virtual methods, and derived classes can override them, which means they provide their own definition and implementation. At run-time, when client code calls the method, the CLR looks up the run-time type of the object, and invokes that override of the virtual method. Thus in your source code you can call a method on a base class, and cause a derived class's version of the method to be executed.
Virtual methods enable you to work with groups of related objects in a uniform way.

For example, suppose you have a drawing application that enables a user to create various kinds of shapes on a drawing surface. You do not know at compile time which specific types of shapes the user will create. However, the application has to keep track of all the various types of shapes that are created, and it has to update them in response to user mouse actions. You can use polymorphism to solve this problem in two basic steps:

  • Create a class hierarchy in which each specific shape class derives from a common base class.
  • Use a virtual method to invoke the appropriate method on any derived class through a single call to the base class method.
Example:

public class Shape
{
// A few example members
public int X { get; private set; }
public int Y { get; private set; }
public int Height { get; set; }
public int Width { get; set; }

// Virtual method
public virtual void Draw()
{
Console.WriteLine("Performing base class drawing tasks");
}
}

class Circle : Shape
{
public override void Draw()
{
// Code to draw a circle...
Console.WriteLine("Drawing a circle");
base.Draw();
}
}
class Rectangle : Shape
{
public override void Draw()
{
// Code to draw a rectangle...
Console.WriteLine("Drawing a rectangle");
base.Draw();
}
}
class Triangle : Shape
{
public override void Draw()
{
// Code to draw a triangle...
Console.WriteLine("Drawing a triangle");
base.Draw();
}
}

class Program
{
static void Main(string[] args)
{
// Polymorphism at work #1: a Rectangle, Triangle and Circle
// can all be used whereever a Shape is expected. No cast is
// required because an implicit conversion exists from a derived
// class to its base class.
System.Collections.Generic.List shapes = new System.Collections.Generic.List();
shapes.Add(new Rectangle());
shapes.Add(new Triangle());
shapes.Add(new Circle());

// Polymorphism at work #2: the virtual method Draw is
// invoked on each of the derived classes, not the base class.
foreach (Shape s in shapes)
{
s.Draw();
}

// Keep the console open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}

}
-----------------------------------------

/* Output:
Drawing a rectangle
Performing base class drawing tasks
Drawing a triangle
Performing base class drawing tasks
Drawing a circle
Performing base class drawing tasks
*/

------------------------------------------



Source: MSDN & Exforsys

Tuesday, November 24, 2009

Class And Objects

Introduction:

In our world we have classes and objects for those classes. Everything in our world is considered to be an object. For example, people are objects, animals are objects too, minerals are objects; everything in the world is an object. Easy, right? But what about classes?

In our world we have to differentiate between objects that we are living with. So we must understand that there are classifications (this is how they get the name and the concepts of the Class) for all of those objects. For example, I'm an object, David is object too, Maria is another object. So we are from a people class (or type). I have a dog called Ricky so it's an object. My friend's dog, Doby, is also an object so they are from a Dogs class (or type).

A C# Class is considered to be the primary building block of the language.

We use classes as a template to put the properties and functionalities or behaviors in one building block for a group of objects and after that we use the template to create the objects we need.

The class: A building block that contains the properties and functionalities that describe some group of objects. We can create a class Person that contains:

1. The properties of any normal person on the earth like: hair color, age, height, weight, eye color.
2. The functionalities or behaviors of any normal person on the earth like: drink water, eat, go to the work.

There are 2 kinds of classes: The built-it classes that come with the .NET Framework, called Framework Class Library, and the programmer defined-classes which we create ourselves.

The class contains data (in the form of variables and properties) and behaviors (in the form of methods to process these data).

The object: It's an object of some classification (or class, or type) and when you create the object you can specify the properties of that object. What I mean here is: I, as an object, can have different properties (hair color, age, height, weight) than you as another object. For example, I have brown eyes and you have green eyes. When I create 2 objects I will specify a brown color for my object's eye color property and I will specify a green color for your object's eye color property.



class Person
{
public int Age;
public string HairColor;
}


This is our simple class which contains 2 variables.

static void Main(string[] args)
{
Person Michael = new Person();
Person Mary = new Person();

// Specify some values for the instance variables
Michael.Age = 20;
Michael.HairColor = "Brown";
Mary.Age = 25;
Mary.HairColor = "Black";
// print the console's screen some of the variable's values
Console.WriteLine("Michael's age = {0}, and Mary's age = {1}",Michael.Age,
Mary.Age);
Console.ReadLine();
}



So we begin our Main method by creating 2 objects of type Person. After creating the 2 objects we initialize the instance variables for object Michael and then for object Mary. Finally we print some values to the console. Here, when you create the Michael object, the C# compiler allocates a memory location for the 2 instance variables to put the values there. Also, the same thing with the Mary object; the compiler will create 2 variables in memory for Mary object. So each object now contains different data.


Using Properties in Functions:

class Person
{
private int age;
private string hairColor;
public int Age
{
get
{
return age;
}
set
{
if(value <= 65 && value >= 18)
{
age = value;
}
else
age = 18;
}
}
public string HairColor
{
get
{
return hairColor;
}
set
{
hairColor = value;
}
}
}


I made some modifications, but focus on the new 2 properties that I created. So the property consists of 2 accessors. The get accessor, responsible of retrieving the variable value, and the set accessor, responsible of modifying the variable's value. So the get accessor code is very simple. We just use the keyword return with the variable name to return its value. So the following code:

get
{
return hairColor;
}


returns the value stored in hairColor.


static void Main(string[] args)
{
Person Michael = new Person();
Person Mary = new Person();

// Specify some values for the instance variables
Michael.Age = 20;
Michael.HairColor = "Brown";
Mary.Age = 25;
Mary.HairColor = "Black";

// print the console's screen some of the variable's values
Console.WriteLine("Michael's age = {0}, and Mary's age = {1}",Michael.Age,
Mary.Age);
Console.ReadLine();
}


Here I created the same objects from the last example, except that I used only properties to access the variable instead of accessing it directly. Look at the following line of code

Michael.Age = 20;

When you assign a value to the property like that C# will use the set accessor. The great thing with the set accessor is that we can control the assigned value and test it; and maybe change to in some cases. When you assign a value to a property C# changes the value in a variable and you can access the variable's value using the reserved keyword value exactly as I did in the example. Let's see it again here.

set
{
if(value <= 65 && value >= 18)
{
age = value;
}
else
age = 18;
}

Here in the code I used if statement to test the assigned value because for some reason I want any object of type Person to be aged between 18 and 65. Here I test the value and if it is in the range then I will simply store it in the variable age. If it's not in the range I will put 18 as a value to age.

We create a class by defining it using the keyword class followed by the class name:

class Person

Then we open a left brace "{" and write our methods and properties. We then close it with a right brace "}". That's how we create a class. Let's see how we create an instance of that class.

In the same way as we declare a variable of type int we create an object variable of Person type with some modifications:

int age;
Person Michael = new Person();


In the first line of code we specified integer variable called age. In the second line we first specified the type of Object we need to create, followed by the object's name, followed by a reserved operator called new. We end by typing the class name again followed by parentheses "()".

Let's understand it step-by-step. Specifying the class name at the beginning tells the C# Compiler to allocate a memory location for that type (the C# compiler knows all the variables and properties and methods of the class so it will allocate the right amount of memory). Then we followed the class name by our object variable name that we want it to go by. The rest of the code "= new Person();" calls the object's constructor. We will talk about constructors later but for now understand that the constructor is a way to initialize your object's variable while you are. For example, the Michael object we created in the last section can be written as following :

Person Michael = new Person(20, "Brown");

Here I specified the variable's values in the parameter list so I initialized the variables while creating the object.


Source: DevArticles

Monday, November 23, 2009

validation in ASP.Net











































TITLE

EXPRESSION

DESCRIPTION

MATCHES

NUMBERS

^[0-9]*$

only numbers are allowed

12345 | 12345678

CURRENCY

^\d+(?:\.\d{0,2})?$

Useful for checking currency amounts, such 5 or 5.00 or 5.25

1 | 1.23 | 1234.45

alpha numeric

^[a-zA-Z0-9]+$

it will check for alphanumeric (Alpha Numeric) values.

adad1213 | 1231dfadfa | dfad123dfasdfs









ASCII Character Set











































Character Entity Number Entity Name Description
" &#34; &quot; quotation mark
' &#39; &apos; (does not work in IE) apostrophe 
& &#38; &amp; ampersand
< &#60; &lt; less-than
> &#62; &gt; greater-than



ISO 8859-1 Symbols:


















































































































































































































































Character Entity Number Entity Name Description
  &#160; &nbsp; non-breaking space
¡ &#161; &iexcl; inverted exclamation mark
¢ &#162; &cent; cent
£ &#163; &pound; pound
¤ &#164; &curren; currency
¥ &#165; &yen; yen
¦ &#166; &brvbar; broken vertical bar
§ &#167; &sect; section
¨ &#168; &uml; spacing diaeresis
© &#169; &copy; copyright
ª &#170; &ordf; feminine ordinal indicator
« &#171; &laquo; angle quotation mark (left)
¬ &#172; &not; negation
­ &#173; &shy; soft hyphen
® &#174; &reg; registered trademark
¯ &#175; &macr; spacing macron
° &#176; &deg; degree
± &#177; &plusmn; plus-or-minus 
² &#178; &sup2; superscript 2
³ &#179; &sup3; superscript 3
´ &#180; &acute; spacing acute
µ &#181; &micro; micro
&#182; &para; paragraph
· &#183; &middot; middle dot
¸ &#184; &cedil; spacing cedilla
¹ &#185; &sup1; superscript 1
º &#186; &ordm; masculine ordinal indicator
» &#187; &raquo; angle quotation mark (right)
¼ &#188; &frac14; fraction 1/4
½ &#189; &frac12; fraction 1/2
¾ &#190; &frac34; fraction 3/4
¿ &#191; &iquest; inverted question mark
× &#215; &times; multiplication
÷ &#247; &divide; division


ISO 8859-1 Characters:


















































































































































































































































































































































































































































Character Entity Number Entity Name Description
À &#192; &Agrave; capital a, grave accent
Á &#193; &Aacute; capital a, acute accent
 &#194; &Acirc; capital a, circumflex accent
à &#195; &Atilde; capital a, tilde
Ä &#196; &Auml; capital a, umlaut mark
Å &#197; &Aring; capital a, ring
Æ &#198; &AElig; capital ae
Ç &#199; &Ccedil; capital c, cedilla
È &#200; &Egrave; capital e, grave accent
É &#201; &Eacute; capital e, acute accent
Ê &#202; &Ecirc; capital e, circumflex accent
Ë &#203; &Euml; capital e, umlaut mark
Ì &#204; &Igrave; capital i, grave accent
Í &#205; &Iacute; capital i, acute accent
Î &#206; &Icirc; capital i, circumflex accent
Ï &#207; &Iuml; capital i, umlaut mark
Ð &#208; &ETH; capital eth, Icelandic
Ñ &#209; &Ntilde; capital n, tilde
Ò &#210; &Ograve; capital o, grave accent
Ó &#211; &Oacute; capital o, acute accent
Ô &#212; &Ocirc; capital o, circumflex accent
Õ &#213; &Otilde; capital o, tilde
Ö &#214; &Ouml; capital o, umlaut mark
Ø &#216; &Oslash; capital o, slash
Ù &#217; &Ugrave; capital u, grave accent
Ú &#218; &Uacute; capital u, acute accent
Û &#219; &Ucirc; capital u, circumflex accent
Ü &#220; &Uuml; capital u, umlaut mark
Ý &#221; &Yacute; capital y, acute accent
Þ &#222; &THORN; capital THORN, Icelandic
ß &#223; &szlig; small sharp s, German
à &#224; &agrave; small a, grave accent
á &#225; &aacute; small a, acute accent
â &#226; &acirc; small a, circumflex accent
ã &#227; &atilde; small a, tilde
ä &#228; &auml; small a, umlaut mark
å &#229; &aring; small a, ring
æ &#230; &aelig; small ae
ç &#231; &ccedil; small c, cedilla
è &#232; &egrave; small e, grave accent
é &#233; &eacute; small e, acute accent
ê &#234; &ecirc; small e, circumflex accent
ë &#235; &euml; small e, umlaut mark
ì &#236; &igrave; small i, grave accent
í &#237; &iacute; small i, acute accent
î &#238; &icirc; small i, circumflex accent
ï &#239; &iuml; small i, umlaut mark
ð &#240; &eth; small eth, Icelandic
ñ &#241; &ntilde; small n, tilde
ò &#242; &ograve; small o, grave accent
ó &#243; &oacute; small o, acute accent
ô &#244; &ocirc; small o, circumflex accent
õ &#245; &otilde; small o, tilde
ö &#246; &ouml; small o, umlaut mark
ø &#248; &oslash; small o, slash
ù &#249; &ugrave; small u, grave accent
ú &#250; &uacute; small u, acute accent
û &#251; &ucirc; small u, circumflex accent
ü &#252; &uuml; small u, umlaut mark
ý &#253; &yacute; small y, acute accent
þ &#254; &thorn; small thorn, Icelandic
ÿ &#255; &yuml; small y, umlaut mark

All Country List in a Dropdownlist c#

using System.Collections.Generic;
using System.Globalization;



Page_Load

{
PopulateCountryName(ddl_country);
}



private void PopulateCountryName(DropDownList dropDown)
{
Hashtable h = new Hashtable();

Dictionary<string, string > objDic = new Dictionary<string, string >();

foreach (CultureInfo ObjCultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{

RegionInfo objRegionInfo = new RegionInfo(ObjCultureInfo.Name);

if (!objDic.ContainsKey(objRegionInfo.EnglishName))
{
objDic.Add(objRegionInfo.EnglishName, objRegionInfo.TwoLetterISORegionName.ToLower());
}
}
List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>(objDic);
myList.Sort(

delegate(KeyValuePair<string, string> firstPair,

KeyValuePair<string, string> nextPair)
{
return firstPair.Value.CompareTo(nextPair.Value);
}
);
foreach (KeyValuePair<string, string> val in myList)
{
dropDown.Items.Add(new ListItem(val.Key, val.Value));
}
}