Translate This Blog

Latest .NET Interview Question

What is a partial class. Give an example?
A partial class is a class whose definition is present in 2 or more files. Each source file contains a section of the class, and all parts are combined when the application is compiled. To split a class definition, use the partial keyword as shown in the example below. Student class is split into 2 parts. The first part defines the study() method and the second part defines the Play() method. When we compile this program both the parts will be combined and compiled. Note that both the parts uses partial keyword and public access modifier.

using System;

namespace PartialClass
{
  public partial class Student
  {
    public void Study()
    {
      Console.WriteLine("I am studying");
    }
  }
  public partial class Student
  {
    public void Play()
    {
      Console.WriteLine("I am Playing");
    }
  }
  public class Demo
  {
    public static void Main()
    {
      Student StudentObject = new Student();
      StudentObject.Study();
      StudentObject.Play();
    }
  }
}

It is very important to keep the following points in mind when creating partial classes.

1.
All the parts must use the partial keyword.
2.
All the parts must be available at compile time to form the final class.
3.
All the parts must have the same access modifiers - public, private, protected etc.
4.
Any class members declared in a partial definition are available to all the other parts.
5.
The final class is the combination of all the parts at compile time.

What are the advantages of using partial classes?

1.
When working on large projects, spreading a class over separate files enables multiple programmers to work on it at the same time.

2.
When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when it creates Windows Forms, Web service wrapper code, and so on. You can create code that uses these classes without having to modify the file created by Visual Studio.

Is it possible to create partial structs, interfaces and methods?

Yes, it is possible to create partial structs, interfaces and methods. We can create partial structs, interfaces and methods the same way as we create partial classes.


Will the following code compile?

using System;
namespace PartialClass
{
  public partial class Student
  {
    public void Study()
    {
      Console.WriteLine("I am studying");
    }
  }
  public abstract partial class Student
  {
    public void Play()
    {
      Console.WriteLine("I am Playing");
    }
  }
  public class Demo
  {
    public static void Main()
    {
      Student StudentObject = new Student();
    }
  }
}

No, a compile time error will be generated stating "Cannot create an instance of the abstract class or interface "PartialClass.Student". This is because, if any part is declared abstract, then the whole class becomes abstract. Similarly if any part is declared sealed, then the whole class becomes sealed and if any part declares a base class, then the whole class inherits that
base class.

Can you create partial delegates and enumerations?

No, you cannot create partial delegates and enumerations.

Can different parts of a partial class inherit from different interfaces?

Yes, different parts of a partial class can inherit from different interfaces.

Can you specify nested classes as partial classes?

Yes, nested classes can be specified as partial classes even if the containing class is not partial. An example is shown below.

class ContainerClass

{
  public partial class Nested
  {
    void Test1() { }
  }
  public partial class Nested
  {
    void Test2() { }
  }
}

How do you create partial methods?

To create a partial method we create the declaration of the method in one part of the partial class and implementation in the other part of the partial class. The implementation is optional. If the implementation is not provided, then the method and all the calls to the method are removed at compile time. Therefore, any code in the partial class can freely use a partial method, even if the implementation is not supplied. No compile-time or run-time errors will result if the method is called but not implemented. In summary a partial method declaration consists of two parts. The definition, and the implementation. These may be in separate parts of a partial class, or in the same part. If there is no implementation declaration, then the compiler optimizes away both the defining declaration and all calls to the method.

The following are the points to keep in mind when creating partial methods.

1.
Partial method declarations must begin partial keyword.
2.
The return type of a partial method must be void.
3.
Partial methods can have ref but not out parameters.
4.
Partial methods are implicitly private, and therefore they cannot be virtual.
5.
Partial methods cannot be extern, because the presence of the body determines whether they are defining or implementing.

What is the use of partial methods?

Partial methods
can be used to customize generated code. They allow for a method name and signature to be reserved, so that generated code can call the method but the developer can decide whether to implement the method. Much like partial classes, partial methods enable code created by a code generator and code created by a human developer to work together without run-time costs.

What is Polymorphism?
Polymorphism means same operation may behave differently on different classes.
Example of Compile Time Polymorphism: Method Overloading
Example of Run Time Polymorphism: Method Overriding

Example of Compile Time Polymorphism

Method Overloading
- Method with same name but with different arguments is called method overloading.
- Method Overloading forms compile-time polymorphism.
- Example of Method Overloading:
class A1
{
            void hello()
            {
                        Console.WriteLine(“Hello”);
            }

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


Example of Run Time Polymorphism

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.
- Example of Method Overriding:
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

When a message can be processed in different ways is called polymorphism. Polymorphism means many forms.
 
Polymorphism is one of the fundamental concepts of OOP.
 
Polymorphism provides following features: 
  • It allows you to invoke methods of derived class through base class reference during runtime.
  • It has the ability for classes to provide different implementations of methods that are called through the same name.
Polymorphism is of two types: 
1.      Compile time polymorphism/Overloading
2.      Runtime polymorphism/Overriding
Compile Time Polymorphism
 
Compile time polymorphism is method and operators overloading. It is also called early binding.
 
In method overloading method performs the different task at the different input parameters.
 

Runtime Time Polymorphism

 
Runtime time polymorphism is done using inheritance and virtual functions. Method overriding is called runtime polymorphism. It is also called late binding.
 
When overriding a method, you change the behavior of the method for the derived class.  Overloading a method simply involves having another method with the same prototype.
 
Caution: Don't confused method overloading with method overriding, they are different, unrelated concepts. But they sound similar.
 
Method overloading has nothing to do with inheritance or virtual methods.
 

Following are examples of methods having different overloads:

 
void area(int side);
void area(int l, int b);
void area(float radius);
 
Practical example of Method Overloading (Compile Time Polymorphism)
 
using System;
 
namespace method_overloading
{
    class Program
    {
        public class Print
        {
           
            public void display(string name)
            {
                Console.WriteLine("Your name is : " + name);
            }
 
            public void display(int age, float marks)
            {
                Console.WriteLine("Your age is : " + age);
                Console.WriteLine("Your marks are :" + marks);
            }
        }
       
        static void Main(string[] args)
        {
 
            Print obj = new Print();
            obj.display("George");
            obj.display(34, 76.50f);
            Console.ReadLine();
        }
    }
}
 
Note: In the code if you observe display method is called two times. Display method will work according to the number of parameters and type of parameters.

 

When and why to use method overloading

 
Use method overloading in situation where you want a class to be able to do something, but there is more than one possibility for what information is supplied to the method that carries out the task.
 
You should consider overloading a method when you for some reason need a couple of methods that take different parameters, but conceptually do the same thing.
 
Method Overloading showing many forms.
 
using System;
 
namespace method_overloading_polymorphism
{
    class Program
    {
        public class Shape
        {
            public void Area(float r)
            {
                float a = (float)3.14 * r;
                // here we have used funtion overload with 1 parameter.
                Console.WriteLine("Area of a circle: {0}",a);
            }
 
            public void Area(float l, float b)
            {
                float x = (float)l* b;
                // here we have used funtion overload with 2 parameters.
                Console.WriteLine("Area of a rectangle: {0}",x);
 
            }
 
            public void Area(float a, float b, float c)
            {
                float s = (float)(a*b*c)/2;
                // here we have used funtion overload with 3 parameters.
                Console.WriteLine("Area of a circle: {0}", s);
            }
        }
 
        static void Main(string[] args)
        {
            Shape ob = new Shape();
            ob.Area(2.0f);
            ob.Area(20.0f,30.0f);
            ob.Area(2.0f,3.0f,4.0f);
            Console.ReadLine();
        }
    }
}
 

Things to keep in mind while method overloading

 
If you use overload for method, there are couple of restrictions that the compiler imposes.
 
The rule is that overloads must be different in their signature, which means the name and the number and type of parameters.
 
There is no limit to how many overload of a method you can have. You simply declare them in a class, just as if they were different methods that happened to have the same name.

Encapsulation is hiding the implementation details which may or may not be for generic or specialized behavior(s).
Abstraction is providing a generalization (say, over a set of behaviors).
Data abstraction in OOP is the concept of abstracting the implemetaion to the user. It just gives the functional description but not the implementaion part.
Take an abstract class or an interface for example, it gives the user some method descriptions, but not the internal implementaion.
  While Encapsulation in OOP is the process of hiding or securing data from outside functions. The data is strictly binded with function members declared in the same class.
For example in C# we can use properties insde the class to manipulte or access the private data declared in the same class, but cannot do so from outside functions.

Encapsulation has two faces; data abstraction and information hiding. Data abstraction is a type seen from the outside. Information hiding is a type seen from the inside.


Sometime encapsulation is used to mean information hiding only but I think the definition I gave is better because if you encapsulate something you get both an inside and an outside right.
————— In Short —————-
Abstraction focuses on the outside view of an object (i.e. the interface)Encapsulation (information hiding) prevents clients from seeing its inside view, where the behavior of the abstraction is implemented.

Encapsulation example
class MyRectangle
{
   private uint width;
   private uint height;
   private uint area;

   public uint Width
   {
      get
      {
         return width;
      }

      set
      {
         width = value;
         ComputeArea();
      }
   }

   public uint Height
   {
      get
      {
         return height;
      }

      set
      {
         height = value;
         ComputeArea();
      }
   }

   public uint Area
   {
      get
      {
         return area;
      }
   }

   private void ComputeArea()
   {
      area = width * height;
   }
}


Can we run asp.net application without WEB.CONFIG file ?

Yes, we can run an asp.net application without the WEB.CONFIG file. It means that the default configuration will be loaded from MACHINE.CONFIG file.
Because all the configuration settings will be available under MACHINE.CONFIG file by default these settings will be applied to all asp.net applications. The MACHINE.CONFIG file will be automitacally loaded when .net framework is installed.
it is something like if we had not defined the web.config the application will take the settings from the machine.config.the machine.config settings are overide by the web.config if u define the web.config for each running appln
In 2005 The VS When we trying to run first time any application the 2005 VS gives us warning that want to run application without beb.config file.
here are three kinds of authentication in ASP.NET:
         i.            Form,
       ii.            Windows, and
      iii.            Passport.
This article will focus on the first type.
·  The windows Authentication provider lets you authenticates users based on their windows accounts. This provider uses IIS to perform the authentication and then passes the authenticated identity to your code. This is the default provided for ASP.net.
·  The passport authentication provider uses Microsoft's passport service to authenticate users.
*Forms authentication provides you with a way to handle authentication using your own custom logic with in an ASP.NET application. The following applies if you choose forms authentication.
1.      When a user requests a page for the application, ASP.NET checks for the presence of a special session cookie. If the cookie is present, ASP.NET assumes the user is authenticated and processes the request.
2.      If the cookie isn't present, ASP.NET redirects the user to a web form you provide
3.      You can carry out whatever authentication, checks you like in your form. When the user is authenticated, you indicate this to ASP.NET by setting a property, which creates the special cookie to handle subsequent requests.
Form authentication is cookie based, as ASP.NET places a cookie in the client machine in order to track the user. If the user requests a secure page and has not logged in, then ASP.NET redirects him/her to the login page. Once the user is authenticated, he/she will be allowed to access the requested page.
  
  
    
 
   
    
   
    
      
      
    
   
 
   
    
      
      
    
   
private void Submit1_Click (object sender, System.EventArgs e)
{
       
    if(this.TextBox_username.Text.Trim()== "HR_manager" 
        && this.TextBox_password.Text.Trim() == "password")     
    {
         // Success, create non-persistent authentication cookie.
         FormsAuthentication.SetAuthCookie(
                 this.TextBox_username.Text.Trim(), flase);       
         FormsAuthenticationTicket ticket1 = 
            new FormsAuthenticationTicket(
                 1,                                   // version
 
                 this.TextBox_username.Text.Trim(),   // get username  from the form
 
                 DateTime.Now,                        // issue time is now
 
                 DateTime.Now.AddMinutes(10),         // expires in 10 minutes
 
                 false,      // cookie is not persistent
 
                 "HR"                              // role assignment is stored
 
                 // in userData
 
                 );
          HttpCookie cookie1 = new HttpCookie(
            FormsAuthentication.FormsCookieName, 
            FormsAuthentication.Encrypt(ticket1) );
          Response.Cookies.Add(cookie1);
 
          // 4. Do the redirect. 
One of the FormsAuthenticationTicket constructors takes the following parameters:
  • version - the version number.
  • name - the user name associated with the ticket.
  • issueDate - the time at which the cookie was issued.
  • expiration - the expiration date for the cookie.
  • isPersistent - true if the cookie is persistent; otherwise, false.
  • userData - user-defined data to be stored in the cookie [MSDN].
          String returnUrl1;
                 // the login is successful
          if (Request.QueryString["ReturnUrl"] == null)
          {
              returnUrl1 = "HRpages/HR_main.aspx";
          }
          else
          {
              returnUrl1 = Request.QueryString["ReturnUrl"];
          }
          Response.Redirect(returnUrl1);
    }
}
============
UDF can be used in a Select, Where, or Case statement. They also can be used to create joins. In addition, User Defined Functions are simpler to invoke than Stored Procedures from inside another SQL statement.

Disadvantages
User Defined Functions cannot be used to modify base table information. The DML statements INSERT, UPDATE, and DELETE cannot be used on base tables. Another disadvantage is that SQL functions that return non-deterministic values are not allowed to be called from inside User Defined Functions. GETDATE is an example of a non-deterministic function. Every time the function is called, a different value is returned. Therefore, GETDATE cannot be called from inside a UDF you create.
CREATE FUNCTION dbo.LookByFName(@FirstLetter char(1))
RETURNS TABLE
AS
RETURN SELECT *
FROM employee
WHERE LEFT(fname, 1) =  @FirstLetter
To use the new function, enter:
SELECT * FROM dbo.LookByFName('A')

User defined functions have 3 main categories
1.      Scalar-valued function - returns a scalar value such as an integer or a timestamp. Can be used as column name in queries
2.      Inline function - can contain a single SELECT statement.
3.      Table-valued function - can contain any number of statements that populate the table variable to be returned. They become handy when you need to return a set of rows, but you can't enclose the logic for getting this rowset in a single SELECT statement.
Differences between Stored procedure and User defined functions
1.      UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
2.      UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
3.      Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowset operations.
4.      Of course there will be Syntax differences and here is a sample of that

# 6
stored procedure is precomplied and not return value by 
default but function compile each time and use return 
statement simply.

store procedure can return Output Parameters where function 
can not return output parameters.
Virtual Method
By declaring base class function as virtual, we allow the function to be overridden in any of derived class.
Eg:
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.
What is enum?
An enumeration is a group of related constants. Each constant is given a descriptive name.
Every enumerated value corresponds to a preset integer.
Sometimes we want to hold a range of particular values or states. This is a perfect place to use enums.
In our example we could have something like
public enum PersonState
{
    Married = 1,
    Widoewed = 2,
    Single = 3,
    Divorced = 4
}
And then call it from our Page_load event
PersonState personstate;
personstate =PersonState.Married;
Response.Write(“
”);
Response.Write(personstate);
C# compiler will  represent these states as particular numeric values . But it will do so behind the curtains.
So I can use the enum name values and have more readable code. The concept of enumerated values is extremely important, because the .NET class library uses it extensively.
What is a structure ?
Structures are lightweight objects. Structures are very similar to classes in C#.
Basically they can hold a collection of different things about a particular item.
They are denoted in C# by the struct keyword. In our example we could have a structure like this
struct NewPerson
{
public string name;
public string surname;
public int age;
public decimal height;
public decimal weight;
}
In the Page_Load event routine we can have
NewPerson myperson;
myperson.name = “John”;
Response.Write(myperson.name);
As you notice there is no need for the new keyword.
There is a key difference between objects and structures. Structures are managed in terms of value while objects are managed in terms of reference.
A reference holds the physical address of where the data is stored in memory. So it points to the data. It is not the actual data. On the other hand structure variables hold the actual data.
There are some limitations with structures and even if they have their place when we design a software component, they can never be used to replace a class type.
A structure  for example can neither inherit another class, nor can they be inherited. A structure can implement interfaces.
A common place where we find structures  are Net framework types like System.Int32, System.Double , System.Boolean.If you want to check it out yourselves just place the pointer of your mouse on an int declaration and right click. From the right-menu click on the “Go To Definition “. Then you will see the definitions. See the picture below.
What is a static class?
In .NET we can  use some class members without creating an object first. These are called static members, and they’re accessed by class name. So far in the previous examples we have seen the static property DateTime.Now to retrieve a DateTime object that represents the current date and time. We didn’ create a DateTime object first.
If we wanted to have a method that determines whether a person can hold a valid driving licence, the method would look like this.
public bool AllowedToDrive(int age)
{
if (age >= 18 || age <= 80)
{
return true;
}
else
{
return false;
}
}
The method above is a good candidate to become a static method.In order to do that, we just add the word static
public static bool AllowedToDrive(int age)
{
if (age >= 18 || age <= 80)
{
return true;
}
else
{
return false;
}
}
In our Page_Load event routine,we can write
Person.AllowedToDrive(22)
As you see we do not need an object to invoke our method, just the class name.
So a static member is a member of the class and not a member of an instance of the class.
It takes some experience to determine which methods or classes. One common place where we find static classes and methods is the creation of libraries that provide general functionality, e.g find the square root of a number, find the perimeter of a circle.
The next thing to review is Interfaces. I will not cover Interfaces in detail because you can find another post of mine on Interfaces on this blog.
The Interface is basically a contract between a the Interface and a class. In the Interface we do not have implementation of properties of methods.
The class that implements the Interface or inherits from the Interface must implement the methods defined in the Interface.
A .NET interface is similar to an abstract class in the sense that it’s a kind of a template. More on abstract classes later.
If we define an interface like this
interface IPerson
{
double DaysVacation(int yearsOfWork);
}
and if we say that the Person class implements the IPerson Interface
class Person : IPerson
the Person class must in its body implement the DaysVacation(int yearsOfWork) method.
public double DaysVacation(int yearsOfWork)
{
if (yearsOfWork > 25)
{
return 25;
}
else if (yearsOfWork < 25 && yearsOfWork > 20)
{
return 20;
}
else
{
return 10;
}
}

Explain the delegates in C#.
Delegates in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.
Here are some features of delegates:

A delegate represents a class.
A delegate is type-safe.
We can use delegates both for static and instance methods
We can combine multiple delegates into a single delegate.
Delegates are often used in event-based programming, such as publish/subscribe.
We can use delegates in asynchronous-style programming.
We can define delegates inside or outside of classes.
Syntax of using delegates

//Declaring delegate
delegate void SampleDelegate(string message);

// declare method with same signature:
static void SampleDelegateMethod(string message) { Console.WriteLine(message); }

// create delegate object
SampleDelegate d1 = SampleDelegateMethod;

// Invoke method with delegate
d1("my program");

using System; 
 
// Declare a delegate.  
delegate string strMod(string str); 
 
public class DelegateTest { 
  // Replaces spaces with hyphens. 
  static string replaceSpaces(string a) { 
    Console.WriteLine("Replaces spaces with hyphens."); 
    return a.Replace(' ', '-'); 
  } 
 
  // Remove spaces. 
  static string removeSpaces(string a) { 
    string temp = ""; 
    int i; 
 
    Console.WriteLine("Removing spaces."); 
    for(i=0; i < a.Length; i++) 
      if(a[i] != ' ') temp += a[i]; 
 
    return temp; 
  }  
 
  // Reverse a string. 
  static string reverse(string a) { 
    string temp = ""; 
    int i, j; 
 
    Console.WriteLine("Reversing string."); 
    for(j=0, i=a.Length-1; i >= 0; i--, j++) 
      temp += a[i]; 
 
    return temp; 
  } 
     
  public static void Main() {  
    // Construct a delegate. 
    strMod strOp = new strMod(replaceSpaces); 
    string str; 
 
    // Call methods through the delegate. 
    str = strOp("This is a test."); 
    Console.WriteLine("Resulting string: " + str); 
    Console.WriteLine(); 
      
    strOp = new strMod(removeSpaces); 
    str = strOp("This is a test."); 
    Console.WriteLine("Resulting string: " + str); 
    Console.WriteLine(); 
 
    strOp = new strMod(reverse); 
    str = strOp("This is a test."); 
    Console.WriteLine("Resulting string: " + str); 
  } 
}
Explain ACID properties of the database?
All Database systems which include transaction support implement ACID properties to ensure the integrity of the database. ACID stands for Atomicity, Consistency, Isolation and Durability
Atomicity: Each transaction is said to be “atomic.” If one part of the transaction fails, the entire transaction fails. Modifications on the data in the database either fail or succeed.
Consistency: This property ensures that only valid data will be written to the database. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back and the database will be restored to a state consistent with those rules.
Isolation: It requires that multiple transactions occurring at the same time not impact each other’s execution.
Durability: It ensures that any transaction committed to the database will not be lost.
We can declare a static class. We use static class when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. .NET Framework common language runtime (CLR) loads Static classes automatically when the program or namespace containing the class is loaded.

Here are some more features of static class

Static classes only contain static members.
Static classes can not be instantiated. They cannot contain Instance Constructors
Static classes are sealed.

What is static member of class?
A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.
To access a static class member, use the name of the class instead of an instance variable
Static methods and Static properties can only access static fields and static events.

Like: int i = Car.GetWheels;
Here Car is class name and GetWheels is static property.

Static members are often used to represent data or calculations that do not change in response to object state.


What is the purpose of Server.MapPath method in Asp.Net?
In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive. Syntax

Suppose your Text files are located at D:\project\MyProject\Files\TextFiles

If the root project directory is MyProject and the aspx file is located at root then to get the same path use code

//Physical path of TextFiles
string TextFilePath=Server.MapPath("Files/TextFiles");


Agile Project Management Tips, Agile Software Development Tips
What is the use of indexes and what are the types of indexes available in SQL Server?
Indexes are used to find data quickly when a query is processed in any relational database. Indexes improve performance by 10 to 500 times.
Index can improve the performance in following operations:

Find the records matching with WHERE clause

UPDATE Books SET Availability = 1 WHERE SubjectId =12
DELETE FROM Books WHERE Price <10
SELECT * FROM Books WHERE Price BETWEEN 50 AND 80

Sorting the result with ORDER BY

SELECT * FROM Books ORDER BY Price DESC

Grouping records and aggregate values

SELECT Count(*) as Units, Price FROM Books GROUP BY Price

There are two types of indexes available in SQL Server: clustered and non-clustered
Clustered index
Clustered index physically reorders the records of a table. Therefore a table can have only one clustered index. Usually a clustered index will be created on the primary key of a table.
Non – Clustered Index
Non – Clustered index are stored in the order of the index key values, but the information in the table is stored in a different order. Means logical sorting of data not Physical. In SQl Server 2005 a table can have 249 non-clustered indexes.
Composite Indexes
A composite index is an index on two or more columns. Both clustered and non-clustered indexes can be composite indexes. If you have composite index on Price and BookName then take can take advantage of it like this:
SELECT BookName, Price FROM Products ORDER BY UnitPrice BookName, Price DESC

What is the difference between abstract class and interface?
We use abstract class and interface where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we declare abstract class.
We can not make instance of Abstract Class as well as Interface. They only allow other classes to inherit from them. And abstract functions must be overridden by the implemented classes. Here are some differences in abstract class and interface.

An interface cannot provide code of any method or property, just the signature. we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract. An abstract class can provide complete code of methods but there must exist a method or property without body.
A class can implement several interfaces but can inherit only one abstract class. Means multiple inheritance is possible in .Net through Interfaces.
If we add a new method to an Interface then we have to define implementation for the new method in every implemented class. But If we add a new method to an abstract class then we can provide default implementation and therefore all the existing code might work properly.
What is the difference between .Net Remoting and Asp.Net Web Services?
ASP.NET Web Services Can be accessed only over HTTP but .Net Remoting Can be accessed over various protocols like TCP, HTTP, SMTP etc.
Web Services are based on stateless service architecture but .Net Remoting support for both stateful and stateless environment.
Web Services support heterogeneous environments means interoperability across platforms but .Net remoting requires .Net on both server and client end.
.NET Remoting provides the fast communication than Web Services when we use the TCP channel and the binary formatter.
Web services support only the objects that can be serialized but .NET Remoting can provide support to all objects that inherit MarshalByRefObject.
Web Services are reliable than .Net remoting because Web services are always hosted in IIS.
Web Services are ease to create and deploy but .Net remoting is bit complex to program. 
What would be the common layers in an n- tier architecture based web application?
Common layers in an n- tier architecture
Presentation GUI: Look & Feel ,Html, aspx file, JavaScript, window forms etc.
Controller- Work flow layer: aspx.cs file, means event handlers and Data binding with controls etc.
Business Logic: where we implement business rules like add book, search library etc.
Data Access: SQLHelper.cs like create connection, get DataSet, Execute Query etc.
Physical Data: tables, views, stored procedures, indexes etc.
What are the different state management techniques used in asp.net for web applications?
In ASP.Net the state can be maintained in following ways
Server-side state management
Application objects
Session Variables
Database
Client-side state management
Cookies
Hidden input fields
Query String
ViewState

How to get records in random order from a sql query in sql server?
In SQL Server we can get records in random order from a sql query using NEWID() Function like:
SELECT Subject FROM dbo.forumThreads ORDER BY NEWID()

1 What is jQuery ? Answers : 1 It's very simple but most valuable Question on jQuery means jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, animating, event handling, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. Jquery is build library for javascript no need to write your own functions or script jquery all ready done for you    
Questions : 2 How you will use Jquery means requirement needed for using jquery
Answers : 2 Nothing more need to do just olny download jquery library(.js file) from any of the jquery site Download jquery and just linked with your html pages like all other javascript file
like below :
< script src="jquery.js" language="javascript" type="text/javascript">     Questions : 3 what the use of $ symbol in Jquery Answers : 3

$ Symbol is just replacement of jquery means at the place of $ you may use jquery hence $ symbol is used for indication that this line used for jquery
    Questions : 4 How do you select an item using css class or ID and get the value by use of jquery
Answers : 4 If an element of html like < div> , < p> or any tag have ID MyId and class used MyClass then we select the element by below jquery code

$('#MyId') for ID and for classs $('.MyClass') and for value

var myValue = $('#MyId').val(); // get the value in var Myvalue by id
Or for set the value in selected item

$('#MyId').val("print me"); // set the value of a form input

 Overview of XSLT
What is the use of XSLT?
XSLT stands for Extensible Stylesheet Language Transformations. This language used in XSL style sheets to transform XML documents into other XML documents.

XSLT is based on template rules which specify how XML documents should be processed. An XSLT processor reads both an XML document and an XSLT style sheet. Based on the instructions the processor finds in the XSLT style sheet, it produce a new XML document. With XSLT we can also produce HTML or XHTML from XML document. With XSLT we can add/remove elements and attributes, rearrange and sort elements, hide and display elements from the output file. Converting XML to HTML for display is probably the most common application of XSLT today.

XSLT stands for EXtensible Stylesheet Language Transformations.

1. XSLT stands for XSL Transformations
2. XSLT transforms an XML document into another XML document
3. XSLT uses XPath to navigate in XML documents
4. XSLT is a W3C Recommendation

As we know XML is light weight and we can also store sensitive data in that.  XSLT is very useful for wireless applications. Using XSLT we can create html pages by traversing a XML document

Below example illustrates how to transform a xml document to html.

XML file

      xxx   abc   USA   2000        xyz   dddd   USA   2000       Abc   dsds   USA   3000       ccc   HR   USA   54545       aaa   Admin   USA   54454545     


XSLT file

 

  http://www.w3.org/1999/XSL/Transform">
       

XYZ Company

                         
     
                             
     
         
NameDept Country Salary
   

Output 

XYZ Company
Name Dept Country Salary
xxx abc USA 2000
xyz dddd USA 2000
Abc dsds USA 3000
ccc HR USA 54545
aaa Admin USA 54454545

Conclusion

XSLT is used to transform an XML document into below format 


   XML document
   HTML
   XHTML

Normally XSLT does this by transforming each XML element into an XHTML element.

What is an abstact class?
If we need to provide common fields and members to all subclasses, we create an Abstract class. We can create an abstract class, with the use of the abstract keyword. Abstract classes cannot be instantiated. In our example if we decide that there are some things that an object of type Person must do, then we can make the class Person abstract and then get the clild classes to provide the implementation. I will create another class to demonstrate abstract classes, because we need to change los of code in the Person class  and I do not want to do that.
In abstract classes we can have abstract members and virtual members. An abstract member is not implemented in the base class and must be implemented in derived classes in order for the class to compile. A virtual member must be implemented in the base class, and if need be (optionally) overriden in the derived class if want the child method to do something different.
Let’s define our abstract Vehicle class.
public abstract class Vehicle
{
public string Model { get; set; }
public string Color { get; set; }
public int NumOfDoors { get; set; }
public int NumoOfWheels { get; set; }
public Vehicle(string model, string color)
{
this.Color = color;
this.Model = model;
}
public abstract string Accelarate(int speed);
public virtual double CalculatePetrolCostPerDistance( double distance)
{
    double costperkilometer=0.25;
    double res;
     res = distance * costperkilometer;
     return res;
}}
Now we can have another class Car that can inherit from the Vehicle class. The method Accelerate in the Vehicle class must be implemented in the child class.
public class Car : Vehicle
{
public Car(string model, string color): base(model,color)
{
          //code to be added
}
public override string Accelarate(int speed)
{
         return “I can accelerate. My speed is right now:”+speed.ToString();
}
public override double CalculatePetrolCostPerDistance(double distance)
{
           double costperkilometer = 0.45;
           double res;
res = distance * costperkilometer;
return res;
}
}
We can create and use an object type Car in our Page_Load event handling routine
Car mycar = new Car( “bmw”, “silver”);
Response.Write(mycar.Accelarate(134));
Response.Write(“
”);
Response.Write(“The cost is: ” + mycar.CalculatePetrolCostPerDistance(125.5).ToString() +” euros”);
In the child class I have implemented a simple version of the Accelarate method by using the override keyword and I chose to ovveride CalculatePetrolCostPerDistance. But If i did not need any different behaviour for the CalculatePetrolCostPerDistance then that would be ok, my class would compile just fine.
Abstract classes are a lot like interfaces, however abstract classes are different in that they contain fully implemented methods alongside the abstract ones.So we do not have to implement the same methods in each of the components that implement a particular interface. An abstract class can contain fields, constructors, or destructors and implement properties while an interface cannot.
An abstract class cannot support multiple inheritance, but an interface can support multiple inheritance. Thus a class may inherit several interfaces but only one abstract class.
What is a namespace?
In my solution in the Default.aspx.cs , I have the namespace LearnCLass namespace. All my classes and code is included in this namespace.
Namespaces are a logical way to group classes. Let me give you an example of what it means. It is a way that we can identify a class beyond doubt.
Imagine that you want to phone an old friend that you have lost track, so you can invite him to your wedding. So you phone the phone directory service.
Your friend’s name is George Patouxas. The operator lets you know that there are 100 people with this name coming up. Then you tell the operator that his mother’s name and father’s name are Maria and John respectively. BINGO!! The operator tells you there is only match. So in our example the LearnCLass.Person class resides in this specific namespace and if someone wants to use it, he can use the using LearnCLass.Person declaration.
That is exactly why namespaces are for in .NET.  We try to group related classes in namespaces and all of them that reside in this particular namespace will be uniquely identified.
If I have a class called Calculate in my LearnClass namespace, then there will be no conflict if need be to use another component from a third party that has also a Calculate Class.
That Calculate class will reside in the AnotherNameSpace so there will be no conflict.
Please note that in the beginning of the Default.aspx.cs we import namespaces that we need to using System.Web.UI;
Assemblies
All .NET classes (built-in or custom made) are contained in assemblies. Assemblies are the physical files that contain compiled code. Assembly files have the extension .exe if they are stand-alone applications or .dll if they’re reusable components. Assemblies are a physical package for distributing code. Often, assemblies and namespaces have the same names. For example, you’ll find the namespace System.Web in the assembly file System.Web.dll.
But in many cases there is no direct mapping between assemblies and namespaces.
What is Casting?
When we talk about casting, we can think of this concept in terms of narrowing and widening. If you move a value from one type to another that narrows the value, it will ask you to explicitly do it yourself. When you move a value from one type to another by widening it, it does not complain.
By widening I mean that if I have the declaration:
int mynum=5;
float anothernum=mynum;
This will be fine because the floating point type can hold all the values supported by the integer type.
If I have this statement (narrowing)
double mynum = 3.5;
float thenum = mynum;
the compiler will complain.
Cannot implicitly convert type ‘double’ to ‘float’. An explicit conversion exists (are you missing a cast?)
The compiler is basically saying “Is there any chance you are discarding information?”
But you can cast the value by using this statement.
double mynum = 3.5;
float thenum = (float)mynum;
This is an explicit conversion and I say in simple words to the compiler, that I take the responsibility for the possible data loss.
For reference types, if we have a situation like this, where the derived type (Student) is converted to base type (Person), we have imlicit conversion which is safe.
Student thestudent = new Student();
while if we type this:
Person theperson=new Person();
this will fail and we must explicitly cast it to the Student type, like this.
Person theperson=new Person();
Student thestudent = (Student)theperson;
Hope it helps. If you need the source code, leave a comment and I will email it to you.
Should I use a #temp table or a @table variable?
In a stored procedure, you often have a need for storing a set of data within the procedure, without necessarily needing that data to persist beyond the scope of the procedure. If you actually need a table structure, there are basically four ways you can "store" this data: local temporary tables (#table_name), global temporary tables (##table_name), permanent tables (table_name), and table variables (@table_name).


Local Temporary Tables
 
CREATE TABLE #people
(
    id INT,
    name VARCHAR(32)
)

A temporary table is created and populated on disk, in the system database tempdb — with a session-specific identifier packed onto the name, to differentiate between similarly-named #temp tables created from other sessions. The data in this #temp table (in fact, the table itself) is visible only to the current scope (usually a stored procedure, or a set of nested stored procedures). The table gets cleared up automatically when the current procedure goes out of scope, but you should manually clean up the data when you're done with it:
 
DROP TABLE #people

This will be better on resources ("release early") than if you let the system clean up *after* the current session finishes the rest of its work and goes out of scope.

A common use of #temp tables is to summarize/compact/reorganize data coming from another stored procedure. So, take this example, which pares down the results of the system procedure sp_who2 into only the SPID, Status, and HostName of *active* processes that are *not* part of the regular operation of the system:
 
CREATE TABLE #sp_who3
(
    SPID INT,
    Status VARCHAR(32) NULL,
    Login SYSNAME NULL,
    HostName SYSNAME NULL,
    BlkBy SYSNAME NULL,
    DBName SYSNAME NULL,
    Command VARCHAR(32) NULL,
    CPUTime INT NULL,
    DiskIO INT NULL,
    LastBatch VARCHAR(14) NULL,
    ProgramName VARCHAR(32) NULL,
    SPID2 INT
)

INSERT #sp_who3 EXEC sp_who2 'active'

SELECT SPID, Status, HostName FROM #sp_who3
    WHERE spid > 15

DROP TABLE #sp_who3

One of the main benefits of using a #temp table, as opposed to a permanent table, is the reduction in the amount of locking required (since the current user is the only user accessing the table), and also there is much less logging involved. (You could also increase this performance by placing tempdb on a separate drive... but that's another story.)

One minor problem with #temp tables is that, because of the session-specific identifier that is tacked onto the name, the name you give it is limited to 116 characters, including the # sign (while other table types are limited to 128). If you try, you will see this:
 
Server: Msg 193, Level 15, State 1, Line 1
The object or column name starting with '#' is too long. The maximum length is 116 characters.

Hopefully this won't be a limitation in your environment, because I can't imagine a table name that long being useful or manageable.
 
Global Temporary Tables
 
CREATE TABLE ##people
(
    id INT,
    name VARCHAR(32)
)

Global temporary tables operate much like local temporary tables; they are created in tempdb and cause less locking and logging than permanent tables. However, they are visible to all sessions, until the creating session goes out of scope (and the global ##temp table is no longer being referenced by other sessions). If two different sessions try the above code, if the first is still active, the second will receive the following:
 
Server: Msg 2714, Level 16, State 6, Line 1
There is already an object named '##people' in the database.

I have yet to see a valid justification for the use of a global ##temp table. If the data needs to persist to multiple users, then it makes much more sense, at least to me, to use a permanent table. You can make a global ##temp table slightly more permanent by creating it in an autostart procedure, but I still fail to see how this is advantageous over a permanent table. With a permanent table, you can deny permissions; you cannot deny users from a global ##temp table.
 


Permanent Tables
 
CREATE TABLE people
(
    id INT,
    name VARCHAR(32)
)

A permanent table is created in the local database, however you can (unlike #temp tables) choose to create a table in another database, or even on another server, for which you have access. Like global ##temp tables, a permanent table will persist the session in which it is created, unless you also explicitly drop the table. (For contention and concurrency reasons, creating a "temporary" permanent table in this manner doesn't really make a lot of sense.) If you are planning to create a permanent table when the procedure runs, you should check to see if it exists, in order to avoid errors like the one mentioned above. For more information about checking for the existence of both local #temp tables and permanent tables, see Article #2458.

Like global ##temp tables, there seems to be little reason to use a permanent table unless the data is going to persist... and if that is the case, why not create the permanent table before the stored procedure is ever run, thereby eliminating all the CREATE / DROP logic?
 
Table Variables
 
DECLARE @people TABLE
(
    id INT,
    name VARCHAR(32)
)

A table variable is created in memory, and so performs slightly better than #temp tables (also because there is even less locking and logging in a table variable). A table variable might still perform I/O to tempdb (which is where the performance issues of #temp tables make themselves apparent), though the documentation is not very explicit about this.

Table variables are automatically cleared when the procedure or function goes out of scope, so you don't have to remember to drop or clear the data (which can be a good thing or a bad thing; remember "release early"?). The tempdb transaction log is less impacted than with #temp tables; table variable log activity is truncated immediately, while #temp table log activity persists until the log hits a checkpoint, is manually truncated, or when the server restarts.

Table variables are the only way you can use DML statements (INSERT, UPDATE, DELETE) on temporary data within a user-defined function. You can create a table variable within a UDF, and modify the data using one of the above statements. For example, you could do this:
 
CREATE FUNCTION dbo.example1
(
)
RETURNS INT
AS
BEGIN
    DECLARE @t1 TABLE (i INT)
    INSERT @t1 VALUES(1)
    INSERT @t1 VALUES(2)
    UPDATE @t1 SET i = i + 5
    DELETE @t1 WHERE i < 7

    DECLARE @max INT
    SELECT @max = MAX(i) FROM @t1
    RETURN @max
END
GO

However, try that with a #temp table:
 
CREATE FUNCTION dbo.example2
(
)
RETURNS INT
AS
BEGIN
    CREATE TABLE #t1 (i INT)
    INSERT #t1 VALUES(1)
    INSERT #t1 VALUES(2)
    UPDATE #t1 SET i = i + 5
    DELETE #t1 WHERE i < 7

    DECLARE @max INT
    SELECT @max = MAX(i) FROM #t1
    RETURN @max
END
GO

Results:
 
Server: Msg 2772, Level 16, State 1, Procedure example2, Line 7
Cannot access temporary tables from within a function.

Or try accessing a permanent table:
 
CREATE TABLE table1
(
    id INT IDENTITY,
    name VARCHAR(32)
)
GO

CREATE FUNCTION dbo.example3
(
)
RETURNS INT
AS
BEGIN
    INSERT table1(name) VALUES('aaron')
    RETURN SCOPE_IDENTITY()
END
GO

Results:
 
Server: Msg 443, Level 16, State 2, Procedure example3, Line 8
Invalid use of 'INSERT' within a function.
So, why not use table variables all the time? Well, when something sounds too good to be true, it probably is. Let's visit some of the limitations of table variables (part of this list was derived from KB #305977): 
Table variables are only allowed in SQL Server 2000+, with compatibility level set to 80 or higher.
 
You cannot use a table variable in either of the following situations:
 
INSERT @table EXEC sp_someProcedure

SELECT * INTO @table FROM someTable

You cannot truncate a table variable.
 
Table variables cannot be altered after they have been declared.
 
You cannot explicitly add an index to a table variable, however you can create a system index through a PRIMARY KEY CONSTRAINT, and you can add as many indexes via UNIQUE CONSTRAINTs as you like. What the optimizer does with them is another story. One thing to note is that you cannot explicitly name your constraints, e.g.:
 
DECLARE @myTable TABLE
(
    CPK1 int,
    CPK2 int,
    CONSTRAINT myPK PRIMARY KEY (CPK1, CPK2)
)

-- yields:
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'CONSTRAINT'.

-- yet the following works:
DECLARE @myTable TABLE
(
    CPK1 int,
    CPK2 int,
    PRIMARY KEY (CPK1, CPK2)
)

You cannot use a user-defined function (UDF) in a CHECK CONSTRAINT, computed column, or DEFAULT CONSTRAINT.
 
You cannot use a user-defined type (UDT) in a column definition.
 
Unlike a #temp table, you cannot drop a table variable when it is no longer necessary—you just need to let it go out of scope.
 
You cannot generate a table variable's column list dynamically, e.g. you can't do this:
 
SELECT * INTO @tableVariable

-- yields:

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '@tableVariable'.

You also can't build the table variable inside dynamic SQL, and expect to use it outside that scope, e.g.:
 
DECLARE @colList VARCHAR(8000), @sql VARCHAR(8000)
SET @colList = 'a INT,b INT,c INT'
SET @sql = 'DECLARE @foo TABLE('+@colList+')'
EXEC(@sql)
INSERT @foo SELECT 1,2,3

-- this last line fails:

Server: Msg 137, Level 15, State 2, Line 5
Must declare the variable '@foo'.

This is because the rest of the script knows nothing about the temporary objects created within the dynamic SQL. Like other local variables, table variables declared inside of a dynamic SQL block (EXEC or sp_executeSQL) cannot be referenced from outside, and vice-versa. So you would have to write the whole set of statements to create and operate on the table variable, and perform it with a single call to EXEC or sp_executeSQL.
 
The system will not generate automatic statistics on table variables. Likewise, you cannot manually create statistics (statistics are used to help the optimizer pick the best possible query plan).
 
An INSERT into a table variable will not take advantage of parallelism.
 
A table variable will always have a cardinality of 1, because the table doesn't exist at compile time.
 
Table variables must be referenced by an alias, except in the FROM clause. Consider the following two scripts:
 
CREATE TABLE #foo(id INT)
DECLARE @foo TABLE(id INT)
INSERT #foo VALUES(1)
INSERT #foo VALUES(2)
INSERT #foo VALUES(3)
INSERT @foo SELECT * FROM #foo

SELECT id
    FROM @foo
    INNER JOIN #foo
    ON @foo.id = #foo.id

DROP TABLE #foo

The above fails with the following error:
 
Server: Msg 137, Level 15, State 2, Line 11
Must declare the variable '@foo'.

This query, on the other hand, works fine:
 
SELECT id
    FROM @foo f
    INNER JOIN #foo
    ON f.id = #foo.id

 
Table variables are not visible to the calling procedure in the case of nested procs. The following is legal with #temp tables:
 
CREATE PROCEDURE faq_outer
AS
BEGIN
    CREATE TABLE #outer
    (
        letter CHAR(1)
    )

    EXEC faq_inner

    SELECT letter FROM #outer

    DROP TABLE #outer
END
GO

CREATE PROCEDURE faq_inner
AS
BEGIN
    INSERT #outer VALUES('a')
END
GO


EXEC faq_outer

Results:
 
letter
------
a

(1 row(s) affected)

However, you cannot do this with table variables. The parser will find the error before you can even create it:
 
CREATE PROCEDURE faq_outer
AS
BEGIN
    DECLARE @outer TABLE
    (
        letter CHAR(1)
    )

    EXEC faq_inner

    SELECT letter FROM @outer
END
GO

CREATE PROCEDURE faq_inner
AS
BEGIN
    INSERT @outer VALUES('a')
END
GO

Results:
 
Server: Msg 137, Level 15, State 2, Procedure faq_inner, Line 4
Must declare the variable '@outer'.

Biggest difference between Temp tables and Table variables in Sql Server

We've all heard about differences between temporary tables and table variables in SQL Server.
They include performance, storage in memory or disk, tempdb use, etc. 
But the biggest and mostly overlooked difference is:
Table variables are Transaction neutral. They are variables and thus aren't bound to a transaction.Temp tables behave same as normal tables and are bound by transactions.
A simple example shows this difference quite nicely:
BEGIN TRAN
declare @var table (id int, data varchar(20) )
create table #temp (id int, data varchar(20) )
 
insert into @var
select 1, 'data 1' union all
select 2, 'data 2' union all
select 3, 'data 3'
 
insert into #temp
select 1, 'data 1' union all
select 2, 'data 2' union all
select 3, 'data 3'
 
select * from #temp
select * from @var
 
ROLLBACK
 
select * from @var
if object_id('tempdb..#temp') is null
    select '#temp does not exist outside the transaction'
 We see that the table variable still exists and has all it's data unlike the temporary table that doesn't exists when the transaction rollbacked. 
.NET Framework encourages cross-language development using multiple programming languages. To become a .NET language, any language should have a compiler that translates the source code written in different languages into Microsoft Intermediate Language (MSIL).

MSIL code is called as Managed Code. Managed code runs in .NET environment.

In .Net framework the Common Runtime Language (CLR) contains a couple of just-in-time compilers (JIT) which can understand IL Code (managed Code), and can convert IL to native code (binary code targeted at a specific machine processor).

Hence any language with IL Code generating compiler can become a .Net language
Delegates in C# are objects which points towards a function which matches its signature. Delegates are reference type used to encapsulate a method with a specific signature. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure.
Here are some features of delegates:
A delegate represents a class.
A delegate is type-safe.
We can use delegates both for static and instance methods
We can combine multiple delegates into a single delegate.
Delegates are often used in event-based programming, such as publish/subscribe.
We can use delegates in asynchronous-style programming.
We can define delegates inside or outside of classes.
Syntax of using delegates

//Declaring delegate
delegate void SampleDelegate(string message);

// declare method with same signature:
static void SampleDelegateMethod(string message) { Console.WriteLine(message); }

// create delegate object
SampleDelegate d1 = SampleDelegateMethod;

// Invoke method with delegate
d1("my program");

Connection pooling enables an application to use a connection from a pool of connections that do not need to be re-established for each use. Once a connection has been created and placed in a connection pool, an application can reuse that connection without performing the complete connection creation process.

By default, the connection pool is created when the first connection with a unique connection string connects to the database. The pool is populated with connections up to the minimum pool size. Additional connections can be added until the pool reaches the maximum pool size.

When a user request a connection, it is returned from the pool rather than establishing new connection and, when a user releases a connection, it is returned to the pool rather than being released. But be sure than your connections use the same connection string each time. Here is the Syntax

conn.ConnectionString = "integrated Security=SSPI; SERVER=192.168.0.123; DATABASE=MY_DB; Min Pool Size=4;Max Pool Size=40;Connect Timeout=14;";
A struct is a value type, while a class is a reference type.
When we instantiate a class, memory will be allocated on the heap. When struct gets initiated, it gets memory on the stack.
Classes can have explicit parameter less constructors. But structs cannot have this.
Classes support inheritance. But there is no inheritance for structs. A struct cannot inherit from another struct or class, and it cannot be the base of a class. Like classes, structures can implement interfaces.
We can assign null variable to class. But we cannot assign null to a struct variable, since structs are value type.
We can declare a destructor in class but can not in struct.
In Microsoft.Net a strong name consists of the assembly's identity. The strong name guarantees the integrity of the assembly. Strong Name includes the name of the .net assembly, version number, culture identity, and a public key token. It is generated from an assembly file using the corresponding private key.
Steps to create strong named assembly:

To create a strong named assembly you need to have a key pair (public key and a private key) file. Use sn -k KeyFile.snk
Open the dot net project to be complied as a strong named assembly. Open AssembyInfo.cs/ AssembyInfo.vb file. Add the following lines to AssemblyInfo file.
[Assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("..\\..\\KeyFile.snk")]
Compile the application, we have created a strong named assembly.
The Common Language Runtime (CLR) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The Microsoft .NET Framework Garbage Collector provides memory management capabilities for managed resources. The Garbage Collector frees objects that are not referenced and reclaims their memory. You should set your references to Nothing(null) as soon as you are done with them to ensure your objects are eligible for collection as soon as possible.
Here are the list of some tasks performed by the Garbage collector:
Garbage collector reserves a piece of memory as the application starts for the managed heap.
Garbage collector controls the managed heap memory currently used and available to an application.
Garbage collector allocates memory for new objects within the application.
The Garbage Collector attempts to reclaim the memory of objects that are not referenced.

We can declare a static class. We use static class when there is no data or behavior in the class that depends on object identity. A static class can have only static members. We can not create instances of a static class using the new keyword. .NET Framework common language runtime (CLR) loads Static classes automatically when the program or namespace containing the class is loaded.

Here are some more features of static class
Static classes only contain static members.
Static classes can not be instantiated. They cannot contain Instance Constructors
Static classes are sealed.

A static member belongs to the class rather than to the instances of the class. In C# data fields, member functions, properties and events can be declared static. When any instances of the class are created, they cannot be used to access the static member.
To access a static class member, use the name of the class instead of an instance variable
Static methods and Static properties can only access static fields and static events.

Like: int i = Car.GetWheels;
Here Car is class name and GetWheels is static property.

Static members are often used to represent data or calculations that do not change in response to object state.
In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive. Syntax

Suppose your Text files are located at D:\project\MyProject\Files\TextFiles

If the root project directory is MyProject and the aspx file is located at root then to get the same path use code

//Physical path of TextFiles
string TextFilePath=Server.MapPath("Files/TextFiles");
In ASP.Net the state can be maintained in following ways
Server-side state management
Application objects
Session Variables
Database
Client-side state management
Cookies
Hidden input fields
Query String
ViewState
In SQL Server we can get records in random order from a sql query using NEWID() Function like:

SELECT Subject FROM dbo.forumThreads ORDER BY NEWID()
ASP.NET Web Services Can be accessed only over HTTP but .Net Remoting Can be accessed over various protocols like TCP, HTTP, SMTP etc.
Web Services are based on stateless service architecture but .Net Remoting support for both stateful and stateless environment.
Web Services support heterogeneous environments means interoperability across platforms but .Net remoting requires .Net on both server and client end.
.NET Remoting provides the fast communication than Web Services when we use the TCP channel and the binary formatter.
Web services support only the objects that can be serialized but .NET Remoting can provide support to all objects that inherit MarshalByRefObject.
Web Services are reliable than .Net remoting because Web services are always hosted in IIS.
Web Services are ease to create and deploy but .Net remoting is bit complex to program.

A master page in ASP.Net provides shared HTML, controls, and code that can be used as a template for all of the pages of a website.
Every master page has asp:contentplaceholder control that will be filled by the content of the pages that use this master page.
You can create a master page that has header and footer i.e. a logo, an image, left navigation bar etc and share this content on multiple pages. You need not to put these things on every aspx page.
Indexes are used to find data quickly when a query is processed in any relational database. Indexes improve performance by 10 to 500 times.
Index can improve the performance in following operations:
Find the records matching with WHERE clause

UPDATE Books SET Availability = 1 WHERE SubjectId =12
DELETE FROM Books WHERE Price <10
SELECT * FROM Books WHERE Price BETWEEN 50 AND 80
Sorting the result with ORDER BY
SELECT * FROM Books ORDER BY Price DESC

Grouping records and aggregate values

SELECT Count(*) as Units, Price FROM Books GROUP BY Price

There are two types of indexes available in SQL Server: clustered and non-clustered
Clustered index
Clustered index physically reorders the records of a table. Therefore a table can have only one clustered index. Usually a clustered index will be created on the primary key of a table.
Non – Clustered Index
Non – Clustered index are stored in the order of the index key values, but the information in the table is stored in a different order. Means logical sorting of data not Physical. In SQl Server 2005 a table can have 249 non-clustered indexes.
Composite Indexes
A composite index is an index on two or more columns. Both clustered and non-clustered indexes can be composite indexes. If you have composite index on Price and BookName then take can take advantage of it like this:
SELECT BookName, Price FROM Products ORDER BY UnitPrice BookName, Price DESC

We use abstract class and interface where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we declare abstract class.
We can not make instance of Abstract Class as well as Interface. They only allow other classes to inherit from them. And abstract functions must be overridden by the implemented classes. Here are some differences in abstract class and interface.
An interface cannot provide code of any method or property, just the signature. we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract. An abstract class can provide complete code of methods but there must exist a method or property without body.
A class can implement several interfaces but can inherit only one abstract class. Means multiple inheritance is possible in .Net through Interfaces.
If we add a new method to an Interface then we have to define implementation for the new method in every implemented class. But If we add a new method to an abstract class then we can provide default implementation and therefore all the existing code might work properly.

Normalization is the process of organizing the table’s data in proper manner.In other words Normalization is the process of breaking up data into a logical non-repetitive format that can be easily reassembled as a whole.
Normalization have 3 different forms namely 1Normal Form,2Normal Form,3Normal Form.
1Normal Form:
A table is said to be in 1NF if it satisfies the following rules.
• The table must not contain any redundant groups of data
• data must be broken up into the smallest units possible. In addition to
breaking data up into the smallest meaningful values.

2Normal Form:
A table is said to be in 2NF if it satisfies the following rules.
• The table must be in 1NF
• All the non-key column must depend on primary key.
3Normal Form:
A table is said to be in 3NF if it satisfies the following rules.
• The table must be in 2NF
• A non-key field should not depend on another Non-key field.
• The data should not be derived further.
For ex:
Below table is in denormalize format:
CustomerName
Region
Product
Quantity
PerProduct
Total
Shivprasad Bist
India,Mumbai
Shirt
2
10
20
Raju Bist
India,Gujrat
Pant
2
30
60
Moosa Shaikh
India,Chennai
Pant
4
15
60
Feroz Shaikh
India,Gujrat
Shirt
2
10
20
Applying Normalization on this table.
1NF:After applying 1NF the table look like
CustomerFirstName
CustomerLastName
Country
State
Product
Quantity
PerProduct
Total
Shivprasad
Bist
India
Mumbai
Shirt
2
10
20
Raju
Bist
India
Gujrat
Pant
2
30
60
Moosa
Shaikh
India
Chennai
Pant
4
15
60
Feroz
Shaikh
India
Gujrat
Shirt
2
10
20
The customer Name is divided into two units like Customer FirstName and
Customer LastName.

Region field is also divided into two units like Country and State.
2NF:After applying 2NF the table look like
CustomerFirstName
CustomerLastName
Country
State
Product
Quantity
PerProduct
Total
Shivprasad
Bist
1
1
2
2
10
20
Raju
Bist
1
2
1
2
30
60
Moosa
Shaikh
1
3
1
4
15
60
Feroz
Shaikh
1
2
2
2
10
20
CountryTable
CountryId
CountryName
StateId
StateName
1
India
1
Mumbai


2
Gujrat


3
Chennai
ProductTable
ProductId
ProductName
1
Pant
2
Shirt
For avoiding duplication Create a new master table of Country and Product.
3NF:After applying 3NF the table look like
CustomerFirstName
CustomerLastName
Country
State
Product
Quantity
PerProduct
Shivprasad
Bist
1
1
2
2
10
Raju
Bist
1
2
1
2
30
Moosa
Shaikh
1
3
1
4
15
Feroz
Shaikh
1
2
2
2
10
A non key field Total is removed from the table.
Explain the Event Life cycle of ASP.NET 2.0?
The events occur in the following sequence. Its best to turn on tracing(<% @Page Trace=”true”%>) and track the flow of events :
PreInit – This event represents the entry point of the page life cycle. If you need to change the Master page or theme programmatically, then this would be the event to do so. Dynamic controls are created in this event.
Init – Each control in the control collection is initialized.
Init Complete* - Page is initialized and the process is completed.
PreLoad* - This event is called before the loading of the page is completed.
Load – This event is raised for the Page and then all child controls. The controls properties and view state can be accessed at this stage. This event indicates that the controls have been fully loaded.
LoadComplete* - This event signals indicates that the page has been loaded in the memory. It also marks the beginning of the rendering stage.
PreRender – If you need to make any final updates to the contents of the controls or the page, then use this event. It first fires for the page and then for all the controls.
PreRenderComplete* - Is called to explicitly state that the PreRender phase is completed.
SaveStateComplete* - In this event, the current state of the control is completely saved to the ViewState.
Unload – This event is typically used for closing files and database connections. At times, it is also used for logging some wrap-up tasks.
The events marked with * have been introduced in ASP.NET 2.0.
You have created an ASP.NET Application. How will you run it?
With ASP.NET 2.0, Visual Studio comes with an inbuilt ASP.NET Development Server to test your pages. It functions as a local Web server. The only limitation is that remote machines cannot access pages running on this local server. The second option is to deploy a Web application to a computer running IIS version 5 or 6 or 7.
Explain the AutoPostBack feature in ASP.NET?
AutoPostBack allows a control to automatically postback when an event is fired. For eg: If we have a Button control and want the event to be posted to the server for processing, we can set AutoPostBack = True on the button.
How do you disable AutoPostBack?
Hence the AutoPostBack can be disabled on an ASP.NET page by disabling AutoPostBack on all the controls of a page. AutoPostBack is caused by a control on the page.
What are the different code models available in ASP.NET 2.0?
There are 2 code models available in ASP.NET 2.0. One is the single-file page and the other one is the code behind page.
Which base class does the web form inherit from?
Page class in the System.Web.UI namespace.
Which are the new special folders that are introduced in ASP.NET 2.0?
There are seven new folders introduced in ASP.NET 2.0 :
\App_Browsers folder – Holds browser definitions(.brower) files which identify the browser and their capabilities.
\App_Code folder – Contains source code (.cs, .vb) files which are automatically compiled when placed in this folder. Additionally placing web service files generates a proxy class(out of .wsdl) and a typed dataset (out of .xsd).
\App_Data folder – Contains data store files like .mdf (Sql Express files), .mdb, XML files etc. This folder also stores the local db to maintain membership and role information.
\App_GlobalResources folder – Contains assembly resource files (.resx) which when placed in this folder are compiled automatically. In earlier versions, we were required to manually use the resgen.exe tool to compile resource files. These files can be accessed globally in the application.
\App_LocalResources folder – Contains assembly resource files (.resx) which can be used by a specific page or control.
\App_Themes folder – This folder contains .css and .skin files that define the appearance of web pages and controls.
 \App_WebReferences folder – Replaces the previously used Web References folder. This folder contains the .disco, .wsdl, .xsd files that get generated when accessing remote web services.
Explain the ViewState in ASP.NET?
Http is a stateless protocol. Hence the state of controls is not saved between postbacks. Viewstate is the means of storing the state of server side controls between postbacks. The information is stored in HTML hidden fields. In other words, it is a snapshot of the contents of a page.
You can disable viewstate by a control by setting the EnableViewState property to false.
What does the EnableViewState property signify?
EnableViewState saves the state of an object in a page between postbacks. Objects are saved in a Base64 encoded string. If you do not need to store the page, turn it off as it adds to the page size.
There is an excellent article by Peter Bromberg to understand Viewstate in depth.
Explain the ASP.NET Page Directives?
Page directives configure the runtime environment that will execute the page. The complete list of directives is as follows:
@ Assembly - Links an assembly to the current page or user control declaratively. 
@ Control - Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).
@ Implements - Indicates that a page or user control implements a specified .NET Framework interface declaratively. 
@ Import - Imports a namespace into a page or user control explicitly.
@ Master - Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.
@ MasterType - Defines the class or virtual path used to type the Master property of a page.
 @ OutputCache - Controls the output caching policies of a page or user control declaratively.
 @ Page - Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.
 @ PreviousPageType - Creates a strongly typed reference to the source page from the target of a cross-page posting.
 @ Reference - Links a page, user control, or COM control to the current page or user control declaratively.
 @ Register - Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.
This list has been taken from here.
Explain the Validation Controls used in ASP.NET 2.0?
Validation controls allows you to validate a control against a set of rules. There are 6 different validation controls used in ASP.NET 2.0.
RequiredFieldValidator – Checks if the control is not empty when the form is submitted.
CompareValidator – Compares the value of one control to another using a comparison operator (equal, less than, greater than etc).
RangeValidator – Checks whether a value falls within a given range of number, date or string.
RegularExpressionValidator – Confirms that the value of a control matches a pattern defined by a regular expression. Eg: Email validation.
CustomValidator – Calls your own custom validation logic to perform validations that cannot be handled by the built in validators.
ValidationSummary – Show a summary of errors raised by each control on the page on a specific spot or in a message box.
How do you indentify that the page is post back?
By checking the IsPostBack property. If IsPostBack is True, the page has been posted back.
What are Master Pages?
Master pages is a template that is used to create web pages with a consistent layout throughout your application. Master Pages contains content placeholders to hold page specific content. When a page is requested, the contents of a Master page are merged with the content page, thereby giving a consistent layout.
How is a Master Page different from an ASP.NET page?
The MasterPage has a @Master top directive and contains ContentPlaceHolder server controls. It is quiet similar to an ASP.NET page.
How do you attach an exisiting page to a Master page?
By using the MasterPageFile attribute in the @Page directive and removing some markup.
How do you set the title of an ASP.NET page that is attached to a Master Page?
By using the Title property of the @Page directive in the content page. Eg:
<@Page MasterPageFile="Sample.master" Title="I hold content" %>
What is a nested master page? How do you create them?
A Nested master page is a master page associated with another master page. To create a nested master page, set the MasterPageFile attribute of the @Master directive to the name of the .master file of the base master page.
What are Themes?
Themes are a collection of CSS files, .skin files, and images. They are text based style definitions and are very similar to CSS, in that they provide a common look and feel throughout the website.
What are skins?
A theme contains one or more skin files. A skin is simply a text file with a .skin extension and contains definition of styles applied to server controls in an ASP.NET page. For eg:

Defines a skin that will be applied to all buttons throughout to give it a consistent look and feel.
What is the difference between Skins and Css files?
Css is applied to HTML controls whereas skins are applied to server controls.
What is a User Control?
User controls are reusable controls, similar to web pages. They cannot be accessed directly.
Explain briefly the steps in creating a user control?
·         Create a file with .ascx extension and place the @Control directive at top of the page.
·         Included the user control in a Web Forms page using a @Register directive
What is a Custom Control?
Custom controls are compiled components that run on the server and that encapsulate user-interface and other related functionality into reusable packages. They can include all the design-time features of standard ASP.NET server controls, including full support for Visual Studio design features such as the Properties window, the visual designer, and the Toolbox.
What are the differences between user and custom controls?
User controls are easier to create in comparison to custom controls, however user controls can be less convenient to use in advanced scenarios.
User controls have limited support for consumers who use a visual design tool whereas custom controls have full visual design tool support for consumers.
A separate copy of the user control is required in each application that uses it whereas only a single copy of the custom control is required, in the global assembly cache, which makes maintenance easier.
A user control cannot be added to the Toolbox in Visual Studio whereas custom controls can be added to the Toolbox in Visual Studio.
User controls are good for static layout whereas custom controls are good for dynamic layout.
Where do you store your connection string information?
The connection string can be stored in configuration files (web.config). 
What is the difference between ‘Web.config’ and ‘Machine.config’?
Web.config files are used to apply configuration settings to a particular web application whereas machine.config file is used to apply configuration settings for all the websites on a web server.
Web.config files are located in the application's root directory or inside a folder situated in a lower hierarchy. The machine.config is located in the Windows directory Microsoft.Net\Framework\Version\CONFIG.
There can be multiple web.config files in an application nested at different hierarchies. However there can be only one machine.config file on a web server.
What is the difference between Server.Transfer and Response.Redirect?
Response.Redirect involves a roundtrip to the server whereas Server.Transfer conserves server resources by avoiding the roundtrip. It just changes the focus of the webserver to a different page and transfers the page processing to a different page.
Response.Redirect can be used for both .aspx and html pages whereas Server.Transfer can be used only for .aspx pages.
Response.Redirect can be used to redirect a user to an external websites. Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.
Response.Redirect changes the url in the browser. So they can be bookmarked. Whereas Server.Transfer retains the original url in the browser. It just replaces the contents of the previous page with the new one.
What method do you use to explicitly kill a users session?
Session.Abandon().
What is a webservice?
Web Services are applications delivered as a service on the Web. Web services allow for programmatic access of business logic over the Web. Web services typically rely on XML-based protocols, messages, and interface descriptions for communication and access. Web services are designed to be used by other programs or applications rather than directly by end user. Programs invoking a Web service are called clients. SOAP over HTTP is the most commonly used protocol for invoking Web services.
What is an application server?
As defined in Wikipedia, an application server is a software engine that delivers applications to client computers or devices. The application server runs your server code. Some well known application servers are IIS (Microsoft), WebLogic Server (BEA), JBoss (Red Hat), WebSphere (IBM).
Compare C# and VB.NET
A detailed comparison can be found over here.
What is a base class and derived class?
A class is a template for creating an object. The class from which other classes derive fundamental functionality is called a base class. For e.g. If Class Y derives from Class X, then Class X is a base class.

The class which derives functionality from a base class is called a derived class. If Class Y derives from Class X, then Class Y is a derived class.
What is an extender class?
An extender class allows you to extend the functionality of an existing control. It is used in Windows forms applications to add properties to controls.
A demonstration of extender classes can be found over here.
What is inheritance?
Inheritance represents the relationship between two classes where one type derives functionality from a second type and then extends it by adding new methods, properties, events, fields and constants.

C# support two types of inheritance:
·         Implementation inheritance
·         Interface inheritance
What is implementation and interface 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.
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.
Source: Exforsys.
What is inheritance hierarchy?
The class which derives functionality from a base class is called a derived class. A derived class can also act as a base class for another class. Thus it is possible to create a tree-like structure that illustrates the relationship between all related classes. This structure is known as the inheritance hierarchy.
How do you prevent a class from being inherited?
In VB.NET you use the NotInheritable modifier to prevent programmers from using the class as a base class. In C#, use the sealed keyword.
When should you use inheritance?
Read this.
Define Overriding?
Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.
Can you use multiple inheritance in .NET?
.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.
Why don’t we have multiple inheritance in .NET?
There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.
What is an Interface?
An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.
When should you use abstract class vs interface or What is the difference between an abstract class and interface?
 What are events and delegates?
An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.
What is business logic?It is the functionality which handles the exchange of information between database and a user interface.
What is a component?Component is a group of logically related classes and methods. A component is a class that implements the IComponent interface or uses a class that implements IComponent interface.
What is a control?A control is a component that provides user-interface (UI) capabilities.
What are design patterns?Design patterns are common solutions to common design problems.
What is a connection pool?A connection pool is a ‘collection of connections’ which are shared between the clients requesting one. Once the connection is closed, it returns back to the pool. This allows the connections to be reused.
What is a flat file?A flat file is the name given to text, which can be read or written only sequentially.
What are functional and non-functional requirements?Functional requirements defines the behavior of a system whereas non-functional requirements specify how the system should behave; in other words they specify the quality requirements and judge the behavior of a system.
E.g.Functional - Display a chart which shows the maximum number of products sold in a region.
Non-functional – The data presented in the chart must be updated every 5 minutes.
What is the global assembly cache (GAC)?
GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dll’s (DLL Hell).
What is a stack? What is a heap? Give the differences between the two?
Stack is a place in the memory where value types are stored. Heap is a place in the memory where the reference types are stored.  
What is instrumentation?
It is the ability to monitor an application so that information about the application’s progress, performance and status can be captured and reported.
What is code review?The process of  examining the source code generally through a peer, to verify it against best practices.
What is logging?Logging is the process of persisting information about the status of an application.
What are mock-ups?Mock-ups are a set of designs in the form of screens, diagrams, snapshots etc., that helps verify the design and acquire feedback about the application’s requirements and use cases, at an early stage of the design process.
What is a Form?
A form is a representation of any window displayed in your application. Form can be used to create standard, borderless, floating, modal windows.
What is a multiple-document interface(MDI)?
A user interface container that enables a user to work with more than one document at a time. E.g. Microsoft Excel.
What is a single-document interface (SDI) ?A user interface that is created to manage graphical user interfaces and controls into single windows. E.g. Microsoft Word
What is BLOB ?A BLOB (binary large object) is a large item such as an image or an exe  represented in binary form.
What is ClickOnce?ClickOnce is a new deployment technology that allows you to create and publish self-updating applications that can be installed and run with minimal user interaction.
What is object role modeling (ORM) ?It is a logical model for designing and querying database models. There are various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise Architects, Infagon etc.
What is a private assembly?A private assembly is local to the installation directory of an application and is used only by that application.
What is a shared assembly?A shared assembly is kept in the global assembly cache (GAC) and can be used by one or more applications on a machine.
What is the difference between user and custom controls?
User controls are easier to create whereas custom controls require extra effort.
User controls are used when the layout is static whereas custom controls are used in dynamic layouts.
A user control cannot be added to the toolbox whereas a custom control can be.
A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.
Where do custom controls reside?In the global assembly cache (GAC).
What is a third-party control ?A third-party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (third-party).
What is a binary formatter?Binary formatter is used to serialize and deserialize an object in binary format.
What is Boxing/Unboxing?Boxing is used to convert value types to object.
E.g. int x = 1;
object obj = x ;
Unboxing is used to convert the object back to the value type.
E.g. int y = (int)obj;
Boxing/unboxing is quiet an expensive operation.
What is a COM Callable Wrapper (CCW)?CCW is a wrapper created by the common language runtime(CLR) that enables COM components to access .NET objects.
What is a Runtime Callable Wrapper (RCW)?RCW is a wrapper created by the common language runtime(CLR) to enable .NET components to call COM components.
What is a digital signature?A digital signature is an electronic signature used to verify/gurantee the identity of the individual who is sending the message.
What is garbage collection?Garbage collection is the process of managing the allocation and release of memory in your applications. Read this article for more information.
What is globalization?Globalization is the process of customizing applications that support multiple cultures and regions.
What is localization?Localization is the process of customizing applications that support a given culture and regions.
What is MIME?The definition of MIME or Multipurpose Internet Mail Extensions as stated in MSDN is “MIME is a standard that can be used to include content of various types in a single message. MIME extends the Simple Mail Transfer Protocol (SMTP) format of mail messages to include multiple content, both textual and non-textual. Parts of the message may be images, audio, or text in different character sets. The MIME standard derives from RFCs such as 2821 and 2822”. Quoted from here.
What is XHTML? Are ASP.NET Pages compliant with XHTML?In simple words, XHTML is a stricter and cleaner version of HTML. XHTML stands for EXtensible Hypertext Markup Language and is a W3C Recommendation.
Yes, ASP.NET 2.0 Pages are XHTML compliant. However the freedom has been given to the user to include the appropriate document type declaration.
Can I deploy the application without deploying the source code on the server?
Yes. You can obfuscate your code by using a new precompilation process called ‘precompilation for deployment’. You can use the aspnet_compiler.exe to precompile a site. This process builds each page in your web application into a single application DLL and some placeholder files. These files can then be deployed to the server.
You can also accomplish the same task using Visual Studio 2005 by using the Build->Publish menu.
Does ViewState affect performance? What is the ideal size of a ViewState? How can you compress a viewstate?
Viewstate stores the state of controls in HTML hidden fields. At times, this information can grow in size. This does affect the overall responsiveness of the page, thereby affecting performance. The ideal size of a viewstate should be not more than 25-30% of the page size.
Viewstate can be compressed to almost 50% of its size. .NET also provides the GZipStream or DeflateStream to compress viewstate. Another option is explained by Scott Hanselmann over here.
How can you detect if a viewstate has been tampered?
By setting the EnableViewStateMac to true in the @Page directive. This attribute checks the encoded and encrypted viewstate for tampering.
Can I use different programming languages in the same application?
Yes. Each page can be written with a different programming language in the same application. You can create a few pages in C# and a few in VB.NET.
Can the App_Code folder contain source code files in different programming languages?
No. All source code files kept in the root App_Code folder must be in the same programming language.
Update: However, you can create two subfolders inside the App_Code and then add both C# and VB.NET in the respective subfolders.  You also have to add configuration settings in the web.config for this to work.
How do you secure your connection string information?
By using the Protected Configuration feature.
How do you secure your configuration files to be accessed remotely by unauthorized users?
ASP.NET configures IIS to deny access to any user that requests access to the Machine.config or Web.config files.
How can I configure ASP.NET applications that are running on a remote machine?
You can use the Web Site Administration Tool to configure remote websites.
How many web.config files can I have in an application?
You can keep multiple web.config files in an application. You can place a Web.config file inside a folder or wherever you need (apart from some exceptions) to override the configuration settings that are inherited from a configuration file located at a higher level in the hierarchy.
I have created a configuration setting in my web.config and have kept it at the root level. How do I prevent it from being overridden by another web.config that appears lower in the hierarchy?
By setting the element's Override attribute to false.

What is the difference between Response.Write and Response.Output.Write?
As quoted by Scott Hanselman, the short answer is that the latter gives you String.Format-style output and the former doesn't. 
To get a detailed explanation, follow this link
What is Cross Page Posting? How is it done?
By default, ASP.NET submits a form to the same page. In cross-page posting, the form is submitted to a different page. This is done by setting the ‘PostBackUrl’ property of the button(that causes postback) to the desired page. In the code-behind of the page to which the form has been posted, use the ‘FindControl’ method of the ‘PreviousPage’ property to reference the data of the control in the first page.
Can you change a Master Page dynamically at runtime? How?
Yes. To change a master page, set the MasterPageFile property to point to the .master page during the PreInit page event.
How do you apply Themes to an entire application?
By specifying the theme in the web.config file.
Eg:





How do you exclude an ASP.NET page from using Themes?
To remove themes from your page, use the EnableTheming attribute of the Page directive.
Your client complains that he has a large form that collects user input. He wants to break the form into sections, keeping the information in the forms related. Which control will you use?
Do webservices support data reader?No. However it does support a dataset.
What is use of the AutoEventWireup attribute in the Page directive ?
The AutoEventWireUp is a boolean attribute that allows automatic wireup of page events when this attribute is set to true on the page. It is set to True by default for a C# web form whereas it is set as False for VB.NET forms. Pages developed with Visual Studio .NET have this attribute set to false, and page events are individually tied to handlers.
What happens when you change the web.config file at run time?ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.
Can you programmatically access IIS configuration settings?
Yes. You can use ADSI, WMI, or COM interfaces to configure IIS programmatically.
How does Application Pools work in IIS 6.0?
As explained under the IIS documentation, when you run IIS 6.0 in worker process isolation mode, you can separate different Web applications and Web sites into groups known as application pools. An application pool is a group of one or more URLs that are served by a worker process or set of worker processes. Any Web directory or virtual directory can be assigned to an application pool.

Every application within an application pool shares the same worker process. Because each worker process operates as a separate instance of the worker process executable, W3wp.exe, the worker process that services one application pool is separated from the worker process that services another. Each separate worker process provides a process boundary so that when an application is assigned to one application pool, problems in other application pools do not affect the application. This ensures that if a worker process fails, it does not affect the applications running in other application pools.

Use multiple application pools when you want to help ensure that applications and Web sites are confidential and secure. For example, an enterprise organization might place its human resources Web site and its finance Web site on the same server, but in different application pools. Likewise, an ISP that hosts Web sites and applications for competing companies might run each companys Web services on the same server, but in different application pools. Using different application pools to isolate applications helps prevent one customer from accessing, changing, or using confidential information from another customers site.
In HTTP.sys, an application pool is represented by a request queue, from which the user-mode worker processes that service an application pool collect the requests. Each pool can manage requests for one or more unique Web applications, which you assign to the application pool based on their URLs. Application pools, then, are essentially worker process configurations that service groups of namespaces.
Multiple application pools can operate at the same time. An application, as defined by its URL, can only be served by one application pool at any time. While one application pool is servicing a request, you cannot route the request to another application pool. However, you can assign applications to another application pool while the server is running.
 What is the Microsoft.NET?
.NET is a set of technologies designed to transform the internet into a full scale distributed platform. It provides new ways of connecting systems, information and devices through a collection of web services. It also provides a language independent, consistent programming model across all tiers of an application.
The goal of the .NET platform is to simplify web development by providing all of the tools and technologies that one needs to build distributed web applications.
What is the .NET Framework?
The .NET Framework is set of technologies that form an integral part of the .NET Platform. It is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.
The .NET Framework has two main components: the common language runtime (CLR) and .NET Framework class library. The CLR is the foundation of the .NET framework and provides a common set of services for projects that act as building blocks to build up applications across all tiers. It simplifies development and provides a robust and simplified environment which provides common services to build application. The .NET framework class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality.
What is CLR?
The .NET Framework provides a runtime environment called the Common Language Runtime or CLR. The CLR can be compared to the Java Virtual Machine or JVM in Java. CLR handles the execution of code and provides useful services for the implementation of the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services. It enforces rules that in turn provide a robust and secure execution environment for .NET applications.
What is CTS?
Common Type System (CTS) describes the datatypes that can be used by managed code. CTS defines how these types are declared, used and managed in the runtime. It facilitates cross-language integration, type safety, and high performance code execution. The rules defined in CTS can be used to define your own classes and values.
What is CLS?
Common Language Specification (CLS) defines the rules and standards to which languages must adhere to in order to be compatible with other .NET languages. This enables C# developers to inherit from classes defined in VB.NET or other .NET compatible languages.
What is managed code?
The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. The code that runs within the common language runtime is called managed code.
What is MSIL?
When the code is compiled, the compiler translates your code into Microsoft intermediate language (MSIL). The common language runtime includes a JIT compiler for converting this MSIL then to native code.
MSIL contains metadata that is the key to cross language interoperability. Since this metadata is standardized across all .NET languages, a program written in one language can understand the metadata and execute code, written in a different language. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.
What is JIT?
JIT is a compiler that converts MSIL to native code. The native code consists of hardware specific instructions that can be executed by the CPU.
Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the JIT converts the MSIL as it is needed during execution. This converted native code is stored so that it is accessible for subsequent calls.
What is portable executable (PE)?
PE is the file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR.

What is an application domain?
Application domain is the boundary within which an application runs. A process can contain multiple application domains. Application domains provide an isolated environment to applications that is similar to the isolation provided by processes. An application running inside one application domain cannot directly access the code running inside another application domain. To access the code running in another application domain, an application needs to use a proxy.
How does an AppDomain get created?
AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application. AppDomains can also be explicitly created by .NET applications.

What is an assembly?
An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the CLR with the information it needs to be aware of type implementations.
What are the contents of assembly?
A static assembly can consist of four elements:
·         Assembly manifest - Contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.
·         Type metadata - Binary information that describes a program.
·         Microsoft intermediate language (MSIL) code.
·         A set of resources.
What are the different types of assembly?
Assemblies can also be private or shared. A private assembly is installed in the installation directory of an application and is accessible to that application only. On the other hand, a shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.
We also have satellite assemblies that are often used to deploy language-specific resources for an application.
What is a dynamic assembly?
A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.
What is a strong name?
You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly.  The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.
What is GAC? What are the steps to create an assembly and add it to the GAC?
The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.
Steps
- Create a strong name using sn.exe tool eg: sn -k mykey.snk
- in AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]
- recompile project, and then install it to GAC in two ways :
·         drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)
·         gacutil -i abc.dll
What is the caspol.exe tool used for?
The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.
What is a garbage collector?
A garbage collector performs periodic checks on the managed heap to identify objects that are no longer required by the program and removes them from memory.
What are generations and how are they used by the garbage collector?
Generations are the division of objects on the managed heap used by the garbage collector. This mechanism allows the garbage collector to perform highly optimized garbage collection. The unreachable objects are placed in generation 0, the reachable objects are placed in generation 1, and the objects that survive the collection process are promoted to higher generations.
What is Ilasm.exe used for?
Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSIL code performs as expected.
What is Ildasm.exe used for?
Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code.
What is the ResGen.exe tool used for?
ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies

What is Ajax?
The term Ajax was coined by Jesse James Garrett and is a short form for "Asynchronous Javascript and XML". Ajax represents a set of commonly used techniques, like HTML/XHTML, CSS, Document Object Model(DOM), XML/XSLT, Javascript and the XMLHttpRequest object, to create RIA's (Rich Internet Applications).
Ajax gives the user, the ability to dynamically and asynchronously interact with a web server, without using a plug-in or without compromising on the user’s ability to interact with the page. This is possible due to an object found in browsers called the XMLHttpRequest object.
What is ASP.NET AJAX?
‘ASP.NET AJAX’ is a terminology coined by Microsoft for ‘their’ implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries.
Which is the current version of ASP.NET AJAX Control Toolkit?
As of this writing, the toolkit version is Version 1.0.20229 (if you are targeting Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005) and Version 3.0.20229 (if targeting .NET Framework 3.5 and Visual Studio 2008).
What role does the ScriptManager play?
The ScriptManager manages all ASP.NET AJAX resources on a page and renders the links for the ASP.NET AJAX client libraries, which lets you use AJAX functionality like PageMethods, UpdatePanels etc. It creates the PageRequestManager and Application objects, which are prominent in raising events during the client life cycle of an ASP.NET AJAX Web page. It also helps you create proxies to call web services asynchronously.
Can we use multiple ScriptManager on a page?No. You can use only one ScriptManager on a page.
What is the role of a ScriptManagerProxy?    A page can contain only one ScriptManager control. If you have a Master-Content page scenario in your application and the MasterPage contains a ScriptManager control, then you can use the ScriptManagerProxy control to add scripts to content pages.
Also, if you come across a scenario where only a few pages in your application need to register to a script or a web service, then its best to remove them from the ScriptManager control and add them to individual pages, by using the ScriptManagerProxy control. That is because if you added the scripts using the ScriptManager on the Master Page, then these items will be downloaded on each page that derives from the MasterPage, even if they are not needed, which would lead to a waste of resources.
What are the requirements to run ASP.NET AJAX applications on a server?
You would need to install ‘ASP.NET AJAX Extensions’ on your server. If you are using the ASP.NET AJAX Control toolkit, then you would also need to add the AjaxControlToolkit.dll in the /Bin folder.
Explain the UpdatePanel?
The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback.
How can you cancel an Asynchronous postback?
Difference between Server-Side AJAX framework and Client-side AJAX framework?
ASP.NET AJAX contains both a server-side Ajax framework and a client-side Ajax framework. The server-side framework provides developers with an easy way to implement Ajax functionality, without having to possess much knowledge of JavaScript. The framework includes server controls and components and the drag and drop functionality. This framework is usually preferred when you need to quickly ajaxify an asp.net application. The disadvantage is that you still need a round trip to the server to perform a client-side action.
The Client-Side Framework allows you to build web applications with rich user-interactivity as that of a desktop application. It contains a set of JavaScript libraries, which is independent from ASP.NET. The library is getting rich in functionality with every new build released.
 How can you debug ASP.NET AJAX applications?Explain about two tools useful for debugging: Fiddler for IE and Firebug for Mozilla.
Can we call Server-Side code (C# or VB.NET code) from javascript?
Yes. You can do so using PageMethods in ASP.NET AJAX or using webservices.
Can you nest UpdatePanel within each other?Yes, you can do that. You would want to nest update panels to basically have more control over the Page Refresh.
How can you to add JavaScript to a page when performing an asynchronous postback?
Use the ScriptManager class. This class contains several methods like the RegisterStartupScript(), RegisterClientScriptBlock(), RegisterClientScriptInclude(), RegisterArrayDeclaration(),RegisterClientScriptResource(), RegisterExpandoAttribute(), RegisterOnSubmitStatement() which helps to add javascript while performing an asynchronous postback.
Explain differences between the page execution lifecycle of an ASP.NET page and an ASP.NET AJAX page?
In an asynchronous model, all the server side events occur, as they do in a synchronous model. The Microsoft AJAX Library also raises client side events. However when the page is rendered, asynchronous postback renders only the contents of the update panel, where as in a synchronous postback, the entire page is recreated and sent back to the browser.
Explain the AJAX Client life-cycle events  Here’s a good article about the same.
Is the ASP.NET AJAX Control Toolkit(AjaxControlToolkit.dll) installed in the Global Assembly Cache?
No. You must copy the AjaxControlToolkit.dll assembly to the /Bin folder in your application.
 Those were some frequently asked questions you should have knowledge about. In one of the coming articles, we will cover some more ASP.NET AJAX FAQ’s which were not covered in this article. I hope this article was useful and I thank you for viewing it.
Explain the .NET architecture.
How many languages .NET is supporting now? - When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.
How is .NET able to support multiple languages? - a language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.
How ASP .NET different from ASP? - Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.
Resource Files: How to use the resource files, how to know which language to use?
What is smart navigation? - The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.
What is view state? - The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
How do you validate the controls in an ASP .NET page? - Using special validation controls that are meant for this. We have Range Validator, Email Validator.
Can the validation be done in the server side? Or this can be done only in the Client side? - Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
How to manage pagination in a page? - Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.
What is ASP.Net? What are the advantages ASP.Net Technologies?
ASP.Net is a server side Technology to develop a web based applications.ASP.Net will make use of .Net framework features.
Advantages of ASP.Net

ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model
ASP.NET offers built-in security features through windows authentication or other authentication methods.
Content and program logic are separated which reduces the inconveniences of program maintenance.
Built-in caching features.
What are different stages of ASP.Net Page Life cycle?
Each ASP.Net Web page performs following stages/events
Page Initialization (Page_Init event)
Page Loading (Page_Load event)
Page Prerender (Page_Prerender)
Page Render (Page_Render)
Page Unload (Page_Unload)
Visit following link for more information at  ASP.Net Page Life Cycle
How do you validate Input data on web page?
Before submitting a web page to server, Input validation on web page is one of the important task.ASP.Net provides below validation controls to validate data in web controls and shows user friendly Messages to the user.
ASP.Net validation Controls

Required field validator control
Compare validator control
Range Validator Control
ASP.Net Interview Questions and answers on validation Controls
what are the different state management techniques in ASP.Net?
Asp.Net state management can be maintained in two ways as below
Client- Side State Management
ASP.Net provides following techniques to store state information. This will improve application performance by minimizing server resource utilization
1.View state
2. Hidden Fields
3. Cookies
4. Query Strings
Server – Side State Management
With respect to Server Side State Management ASP.Net uses “Application state” and “Session state” objects to store data or user state.

What are the differences between custom Web control and user control?
Custom Web control is a control that inherits from web server control available in ASP.Net.
A Custom Web Control could be compiled into separate .dll file. This custom Web control can be shared across all application by installing this dll in to Global Assembly Catch.

User Control is a file (.ascx file) that contains a set of ASP.Net controls and code grouped together to provide common functionality across the application. User control can be used on different web pages of the application.
Explain ASP.Net Catching? What are different catching mechanisms available in ASP.Net?
ASP.Net catching one of the important performance factor for large web applications.
ASP.Net Catching stores frequently accessed data in to catch object.
There are two different types catching in ASP.Net
1.Application Catching
2.Page Output Catching

1.What is the difference between Response.Write() and Response.Output.Write()?
Ans.Response.Output.Write() allows you to write formatted output.

2.What is the difference between Server.Transfer and Response.Redirect?

Ans.Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client’s browser.This provides a faster response with a little less overhead on the server.Server.Transfer does not update clients url historylist or current url.
Response.Redirect is used to redirect the user’s browser to another page or site.This performs a trip back to the client where client’s browser is redirected to the new page.The user’s browser history list is updated to reflect the new address.
3.Explain the difference between server-side code and client-side code.
Ans.Server-side code executes on the server.Client-side code executes on the client’s browser.
4.Describe the difference between inline code and code behind.
Ans.Inline code written along side the html in a page.Code-behind is code written in seprate file and refrenced by .aspx in page.
5.What methods are fired during page load?
Ans. Init() – when the page is instantiated
Load() – when the page is loaded into server memory
PreRender() – the brief moment before the page is displayed to the user as HTML
Unload() – when page finishes loading.
6.What data types do the RangeValidator control supports?
Ans. Integer,String and Date.
7.What is ViewState?
Ans. ViewState is the mechanism by which page state (information) is maintained between page post backs, i.e. a web form is submitted by the user, this same page performs some processing and perhaps presents further information to the user.ViewState allows the state of objects(serializable) to be stored in a hidden field on the page.
8.Can any object be stored in a ViewState?
Ans. An object that either is serializable or has a TypeConverter defined for it can be persisted in ViewState.
9. What should you do to store an object in a Viewstate?
Ans. Do serialization of convert the object to string
10.Explain how Viewstate is being formed and how it’s stored on client.
Ans.The type of ViewState is System.Web.UI.StateBag, which is a dictionary that stores name/value pairs. ViewState is persisted to a string variable by the ASP.NET page framework and sent to the client and back as a hidden variable. Upon postback, the page framework parses the input string from the hidden variable and populates the ViewState property of each control. If a control uses ViewState for property data instead of a private field, that property automatically will be persisted across round trips to the client. (If a property is not persisted in ViewState, it is good practice to return its default value on postback.)
11. Where is ViewState information stored ?
Ans. ViewState information is stored in hidden fields.
12. What are benefits and Limitation of using Hidden fields ?
Ans. The benefits of using hidden fields to store client-side state include:
• No server resources are required. The hidden field is stored and read directly from the page.
• Almost all browsers and client devices support forms with hidden fields.
• Hidden fields are simple to implement.
• Hidden fields are good for caching data in Web farm configurations because the data is cached on the client.
The limitations of using hidden fields are:
• The hidden field can be tampered with. The information in this field can be seen if the page output source is viewed directly, creating a potential security issue.
• The hidden field does not support rich structures; it offers only a single value field in which to place information. To store multiple values, you must implement delimited strings and write the code required to parse those strings.
• Page performance decreases when you store large values because hidden fields are stored in the page.
13.How can you use Hidden frames to cache client data ?
Ans. You can use hidden frames to cache data on the client, avoiding the roundtrips to the server that are inherent in hidden field and view state implementations. You create a hidden frame in your page that loads a Web page into the frame containing your data. The pages in your application can access this data using client-side scripting. This implementation does not require any server resources because the data fields in the hidden frame are stored and read directly from the page.
14.What are benefits and Limitation of using Hidden frames?
Ans. The benefits of using hidden frames to store client-side state include:
• The ability to cache more than one data field.
• The avoidance of roundtrips of data during postbacks.
• The ability to cache and access data items stored in different hidden forms.
• The ability to access JScript® variable values stored in different frames if they come from the same site.
The limitations of using hidden frames are:
• Functionality of hidden frames is not supported by all browsers. Do not rely on hidden frames to provide data for the essential functionality of your pages.
• The hidden frame can be tampered with, and the information in the page can be seen if the page output source is viewed directly, creating a potential security threat.
• There is no limit to the number of frames (embedded or not) that you can hide. In frames that bring data from the database and that contain several Java applets or images, a large number of frames can negatively affect performance of the first page load.
15.What is Global.asax used for?
Ans.The Global.asax is used to implement application and session level events.
16. What are major events in GLOBAL.ASAX file ?
Ans. The Global.asax file, which is derived from the HttpApplication class, maintains a pool of HttpApplication objects, and assigns them to applications as needed. The Global.asax file contains the following events:
• Application_Init: Fired when an application initializes or is first called. It’s invoked for all HttpApplication object instances.
• Application_Disposed: Fired just before an application is destroyed. This is the ideal location for cleaning up previously used resources.
• Application_Error: Fired when an unhandled exception is encountered within the application.
• Application_Start: Fired when the first instance of the HttpApplication class is created. It allows you to create objects that are accessible by all HttpApplication instances.
• Application_End: Fired when the last instance of an HttpApplication class is destroyed. It’s fired only once during an application’s lifetime.
• Application_BeginRequest: Fired when an application request is received. It’s the first event fired for a request, which is often a page request (URL) that a user enters.
• Application_EndRequest: The last event fired for an application request.
• Application_PreRequestHandlerExecute: Fired before the ASP.NET page framework begins executing an event handler like a page or Web service.
• Application_PostRequestHandlerExecute: Fired when the ASP.NET page framework is finished executing an event handler.
• Applcation_PreSendRequestHeaders: Fired before the ASP.NET page framework sends HTTP headers to a requesting client (browser).
• Application_PreSendContent: Fired before the ASP.NET page framework sends content to a requesting client (browser).
• Application_AcquireRequestState: Fired when the ASP.NET page framework gets the current state (Session state) related to the current request.
• Application_ReleaseRequestState: Fired when the ASP.NET page framework completes execution of all event handlers. This results in all state modules to save their current state data.
• Application_ResolveRequestCache: Fired when the ASP.NET page framework completes an authorization request. It allows caching modules to serve the request from the cache, thus bypassing handler execution.
• Application_UpdateRequestCache: Fired when the ASP.NET page framework completes handler execution to allow caching modules to store responses to be used to handle subsequent requests.
• Application_AuthenticateRequest: Fired when the security module has established the current user’s identity as valid. At this point, the user’s credentials have been validated.
• Application_AuthorizeRequest: Fired when the security module has verified that a user can access resources.
• Session_Start: Fired when a new user visits the application Web site.
• Session_End: Fired when a user’s session times out, ends, or they leave the application Web site.
17.How do you validate the controls in ASP.NET page?
Ans. Using the validation controls that are meant for this.
18. Which control is used to make sure the values in two different controls are matched?
Ans. CompareValidator control.
19.Name two properties common in every validation control.
Ans.ControlToValidate property and Text property.
20. Can the validation be done in the server side? Or this can be done only in the Client side?
Ans. Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.
21. How to manage pagination in a page?
Ans. Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.
22. Which are various modes of storing ASP.NET session?
Ans. ASP.Net Session State supports three modes. inproc, sqlserver, and stateserver.
• InProc – session kept as live objects in web server (aspnet_wp.exe). Use “cookieless” configuration in web.config to “munge” the sessionId onto the URL (solves cookie/domain/path RFC problems too!)
• StateServer – session serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine
• SQLServer – session serialized and stored in SQL server
23. Is Session_End event supported in all session modes ?
Ans. Session_End event only supported in inproc mode when the session data is stored in the asp.net worker process.
24. What are the precautions you will take in order that StateServer Mode work properly ?
Ans. Following are the things to remember so that StateServer Mode works properly :-
• StateServer mode session data is stored in a different process so you must
ensure that your objects are serializable.
• elements in Web.config should be indentical across all
servers.So this ensures that encryption format is same across all computers.
• IIS metabase (\LM\W3SVC\2) must be identical across all servers in that
farm.
25. What are the precautions you will take in order that SQLSERVERMode work properly ?
Ans.Following are the things to remember so that SQLSERVER Mode works properly.
• SQLSERVER mode session data is stored in a different process so you must ensure that your objects are serializable.
• IIS metabase (\LM\W3SVC\2) must be indentical across all servers in that farm.
• By default Session objects are stored in “Tempdb” , you can configure it store outside “TempDB” by running microsoft provided SQL script.
Note :- “TempDB” database is re-created after SQL SERVER computer reboot.If you want to maintain session state with every reboot best is to run SQL Script and store session objects outside “TempDB” database.
26. Where do you specify session state mode in ASP.NET ?
Ans. stateConnectionString=”tcpip=192.168.1.1:42424″
sqlConnectionString=”data source=192.168.1.1; Integrated
Security=SSPI”
cookieless=”false”
timeout=”20″
Above is sample session state mode specified for SQL SERVER.
27. What are the other ways you can maintain state ?
Ans.Other than session variables you can use the following technique to store state :
• Hidden fields
• View state
• Hidden frames
• Cookies
• Query strings
28. What are benefits and Limitation of using Cookies?
Ans.Following are benefits of using cookies for state management :-
• No server resources are required as they are stored in client.
• They are light weight and simple to use
Following are limitation of using cookies :-
• Most browsers place a 4096-byte limit on the size of a cookie,although support
for 8192-byte cookies is becoming more common in the new browser and
client-device versions available today.
• Some users disable their browser or client device’s ability to receive cookies,
thereby limiting the use of cookies.
• Cookies can be tampered and thus creating a security hole.
• Cookies can expire thus leading to inconsistency.
Below is sample code of implementing cookies
Request.Cookies.Add(New HttpCookie(“name”, “user1”))
29. What is Query String and What are benefits and Limitation of using Query Strings?
Ans.A query string is information sent to the server appended to the end of a page URL.
Following are the benefits of using query string for state management:-
• No server resources are required. The query string is contained in the HTTP request for a specific URL.
• All browsers support query strings.
Following are limitations of query string :-
• Query string data is directly visible to user thus leading to security problems.-
• Most browsers and client devices impose a 255-character limit on URL length.
Below is a sample “Login” query string passed in URL http://www.querystring.com/
login.asp?login=testing.This querystring data can then be requested later by using
Request.QueryString(“login”).
30. What is application object ?
Ans.Application object can used in situation where we want data to be shared across users globally.
31.What’s the difference between Cache object and application object?
Ans.The main difference between the Cache and Application objects is that the Cache object provides cache-specific features, such as dependencies and expiration policies.
32.How can get access to cache object ?
Ans.The Cache object is defined in the System.Web.Caching namespace. You can get a reference to the Cache object by using the Cache property of the HttpContext class in the System.Web namespace or by using the Cache property of the Page object.
33.What are dependencies in cache and types of dependencies ?
Ans.When you add an item to the cache, you can define dependency relationships that can force that item to be removed from the cache under specific activities of dependencies.Example if the cache object is dependent on file and when the file data changes you want the cache object to be update.Following are the supported dependency.
• File dependency :- Allows you to invalidate a specific cache item when a disk based file or files change.
• Time-based expiration :- Allows you to invalidate a specific cache item depending on predefined time.
• Key dependency :-Allows you to invalidate a specific cache item depending when another cached item changes.
34.Can you show a simple code showing file dependency in cache ?
Ans.Partial Class Default_aspx
Public Sub displayAnnouncement()
Dim announcement As String
If Cache(“announcement”) Is Nothing Then
Dim file As New _
System.IO.StreamReader _
(Server.MapPath(“announcement.txt”))
announcement = file.ReadToEnd
file.Close()
Dim depends As New _
System.Web.Caching.CacheDependency _
(Server.MapPath(“announcement.txt”))
Cache.Insert(“announcement”, announcement, depends)
End If
Response.Write(CType(Cache(“announcement”), String))
End Sub
Private Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init
displayAnnouncement()
End Sub
End Class
Note :- Above source code can be obtained from CD in “CacheSample”
folder.”Announcement.txt” is in the same folder which you can play around to see the results.
Above given method displayAnnouncement() displays banner text from Announcement.txt file which is lying in application path of the web directory.Above method first checks is the Cache object nothing , if the cache object is nothing then it moves further to load the cache data from the file.Whenever the file data changes the cache object is removed and set to nothing.
35.What is Cache Callback in Cache ?
Ans.Cache object is dependent on its dependencies example file based , time based etc.Cache items remove the object when cache dependencies change.ASP.NET provides capability to execute a callback method when that item is removed from cache.
36. What is scavenging ?
Ans.When server running your ASP.NET application runs low on memory resources , items are removed from cache depending on cache item priority.cache item priority is set when you add item to cache.BY setting the cache item priority controls which items scavenging is removed first.
37. What are different types of caching using cache object of ASP.NET?
Ans.You can use two types of output caching to cache information that is to be transmitted to and displayed in a Web browser:
• Page Output Caching
Page output caching adds the response of page to cache object.Later when page is requested page is displayed from cache rather than creating the page object and displaying it.Page output caching is good if the site is fairly static.
• Page Fragment Caching
If parts of the page are changing, you can wrap the static sections as user controls and cache the user controls using pagefragment caching.
38. How can you cache different version of same page using ASP.NET cache object ?
Ans.Output cache functionality is achieved by using “OutputCache” attribute on ASP.NET page header.Below is the syntax
• VaryByParam :- Caches different version depending on input parameters send through HTTP POST/GET.
• VaryByHeader:- Caches different version depending on the contents of the page header.
• VaryByCustom:-Lets you customize the way the cache handles page variations by declaring the attribute and overriding the GetVaryByCustomString handler.
• VaryByControl:-Caches different versions of a user control based on the value of properties of ASP objects in the control.
39. How will implement Page Fragment Caching ?
Ans.Page fragment caching involves the caching of a fragment of the page, rather than the entire page. When portions of the page need to be dynamically created for each user request this is best method as compared to page caching.You can wrap Web Forms user control and cache the control so that these portions of the page don’t need to be recreated
each time.
40. What’s the sequence in which ASP.NET events are processed?
Ans.
1. Initialize: Initialize settings needed during the lifetime of the incoming Web request.
2. Load view state: At the end of this phase, the ViewState property of a control is automatically populated
3. Process postback data: Process incoming form data and update properties accordingly.
4. Load: Perform actions common to all requests, such as setting up a database query. At this point, server controls in the tree are created and initialized, the state is restored, and form controls reflect client-side data.
5. Send postback change notifications: Raise change events in response to state changes between the current and previous postbacks.
6. Handle postback events: Handle the client-side event that caused the postback and raise appropriate events on the server.
7. Prerender: Perform any updates before the output is rendered. Any changes made to the state of the control in the prerender phase can be saved, while changes made in the rendering phase are lost.
8. Save state: The ViewState property of a control is automatically persisted to a string object after this stage. This string object is sent to the client and back as a hidden variable. For improving efficiency, a control can override the SaveViewState method to modify the ViewState property.
9. Render: Generate output to be rendered to the client.
10. Dispose: Perform any final cleanup before the control is torn down. References to expensive resources such as database connections must be released in this phase.
11. Unload: Perform any final cleanup before the control is torn down. Control authors generally perform cleanup in Dispose and do not handle this event.
Initialization, Page Load, PreRendor, Page unload
41. What is event bubbling ?
Ans. Event Bubbling is nothing but events raised by child controls is handled by the parent control. Example: Suppose consider datagrid as parent control in which there are several child controls.There can be a column of link buttons right.Each link button has click event.Instead of writing event routine for each link button write one routine for parent which will handlde the click events of the child link button events.Parent can know which child actaully triggered the event.That thru arguments passed to event routine.
42. How do we assign page specific attributes ?
Ans. @Page directive defines page-specific attributes used in ASP.NET pages(.aspx). @Page directives allow you to set attributes that directly affect your ASP.NET pages that end with the .aspx extension. The following is a small example of what an @Page directive looks like:<%@ page language=”c#” buffer=”true” Explicit=”true” runat=”server” %>
43. What’s the use of @ Register directives ?
Ans. @ Register Creates an association between a tag prefix and a custom control, which provides developers with a concise way to refer to custom controls in an ASP.NET application file (including Web pages, user controls, and master pages).
44. What’s the use of SmartNavigation property ?
Ans. A SmartNavigation is a property of the Page class in System.Web.UI. When a request comes in to Internet Explorer 5.5 or higher and SmartNavigation is turned on (set to true), the following actions are performed: The flash caused by navigation is eliminated The scroll position is persisted when moving from page to page Element focus is persisted between navigations Only the last page state in the browser’s history is retained However, according to the Microsoft® .NET Framework Class Library documentation, smart navigation is best used only with ASP.NET pages that require frequent postbacks but have visual content that does not change dramatically on return.In most circumstances, you should not set this property in code. Set the SmartNavigation attribute to true in the @ Page directive in the .aspx file. When the page is requested, the dynamically generated class sets this property for you. Smart navigation is a feature that you must test in your particular scenarios to be sure the proper behavior is exhibited.
45. What is AppSetting Section in “Web.Config” file ?
Ans. The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.
46What’s the use of @ OutputCache directive in ASP.NET?Ans.@ OutputCacheDeclaratively controls the output caching policies of an ASP.NET page or a user control contained in a page.
47.How can we create custom controls in ASP.NET?
Ans. custom controls can be created in either of the following 3 methods.
1. Creating as a composite control : This method uses and combines the existing controls to give a custom functionality which can be used across different projects by adding to the control library. This can provide for event bubbling from child controls to the Parent container, custom event handling and properties. The CreateChildControls function of the Control class should be overridden for creating this custom control. This can also support design time rendering of the control.
2. Deriving from an existing control : This method of creating a custom control derives from an existing ASP .Net control and customizing the properties that we need. This also can support custom event handling, properties etc.,
3. Creating a control from Scratch : This method is the one which needs maximum programming. This method needs even the HTML code for the custom controls to be written by the programmer. This may also need one to implement the IPostBackDataHandler and IPostBackEventHandler interfaces. A detailed explanation with example for this is available at Rendering Custom Controls Sample in MSDN.

48. How many types of validation controls are provided by ASP.NET ?
Ans.RequiredField Validator Control,Range Validator Control, RegularExpression Validator Control,Custom Validator Control and Validation Summary Control are provided by ASP.NET.
49. Can you explain what is “AutoPostBack” feature in ASP.NET ?
Ans. AutoPostBack is built into the form-based server controls, and when enabled, automatically posts the page back to the server whenever the value of the control in question is changed.
50. How can you enable automatic paging in DataGrid ?
Ans. Using the Built-In Paging Controls
To use default paging, you set properties to enable paging, set the page size, and specify the style of the paging controls. Paging controls are LinkButton controls. You can choose from these types: Next and previous buttons. The button captions can be any text you want. Page numbers, which allow users to jump to a specific page. You can specify how many numbers are displayed; if there are more pages, an ellipsis ( … ) is displayed next to the numbers. You must also create an event-handling method that responds when users click a navigation control.
To use the built-in paging controlsSet the control’s AllowPaging property to true. Set the PageSize property to the number of items to display per page.
To set the appearance of the paging buttons, include a element into the page as a child of the DataGrid control. For syntax, see DataGrid Control Syntax. Create a handler for the grid’s PageIndexChanged event to respond to a paging request. The DataGridPageChangedEventsArgs enumeration contains the NewPageIndex property, which is the page the user would like to browse to. Set the grid’s CurrentPageIndex property to e.NewPageIndex, then rebind the data.
51. What’s the difference between “Web.config” and “Machine.Config” ?
Ans. machine.config is where u define all the machine specific settings.. common for all the web application..
web.config is where u define all the setings for that perticular web application.. it override the machine.config settings for application.

52. What’s the difference between login controls and Forms authentication?
Ans.Login controls are an easy way to implement Forms authentication without having to write any code. For example, the Login control performs the same functions you would normally perform when using the FormsAuthentication class—prompt for user credentials, validate them, and issue the authentication ticket—but with all the functionality wrapped in a control that you can just drag from the Toolbox in Visual Studio. Under the covers, the login control uses the FormsAuthentication class (for example, to issue the authentication ticket) and ASP.NET membership (to validate the user credentials). Naturally, you can still use Forms authentication yourself, and applications you have that currently use it will continue to run.

53. What’s difference between Authentication and authorization?
Ans. Authentication is the process of identifying and verifying who the client accessing the server is.
For example, if you use

* Windows authentication and are browsing an ASP.NET page from server — ASP.NET/IIS would automatically use NTLM to authenticate you as SYNCFUSION\user1 (for example).
* Forms based authentication, then you would use an html based forms page to enter username/password — which would then check a database and authenticate you against the username/password in the database.

Authorization is the process of determining whether an authenticated user has access to run a particular page within an ASP.NET web application. Specifically, as an application author decide to grant or deny the authenticated user “SYNCFUSION\user1″ access to the admin.aspx page. This could be done either by explictly granting/denying rights based on the username — or use role based mappings to map authenticated users into roles.
54. What are the various ways of authentication techniques in ASP.NET?
Ans. ASP.NET provides three ways to authenticate a user:
* Windows authentication,
* Forms authentication, and
* Passport authentication

55. What’s difference between Datagrid , Datalist and repeater ?
Ans. Datagrid is most restrictive as regards to customization followed by DataList and finally Repeater is the most customizable.Datagrid has built in paging, sorting and editing capabilities which are not there with the other two controls. So if you want users to sort / page / edit data, datagrid is the natural choice.DataList and repeater have better performance than datagrid. So if performance is a major concern, for example, a site with large number of concurrent visitors, then you could think of datalist or repeater.Repeater is the most customizable. It allows you to create structures like nested lists, for example.A datagrid row displays one record from the data source, while a datalist row can display more than one records (set by RepeatColumns property)Datagrid and Datalist are derived from WebControl while Repeater is not, and so does not have the stylistic properties of web controls.All are similar in that they have a datasource property and ItemCreated, ItemDataBound and ItemCommand events.
56. What is Tracing in ASP.NET ?
Ans. ASP.NET introduces new functionality that allows you to write debug statements, directly in your code, without having to remove them from your application when it is deployed to production servers. Called tracing, this feature allows you to write variables or structures in a page, assert whether a condition is met, or simply trace through the execution path of your page or application.
57. How do we enable tracing ?
Ans.Instead of enabling tracing for individual pages, you can enable it for your entire application. In that case, every page in your application displays trace information. Application tracing is useful when you are developing an application because you can easily enable it and disable it without editing individual pages. When your application is complete, you can turn off tracing for all pages at once.When you enable tracing for an application, ASP.NET collects trace information for each request to the application, up to the maximum number of requests you specify. The default number of requests is 10. You can view trace information with the trace viewer.By default, when the trace viewer reaches its request limit, the application stops storing trace requests. However, you can configure application-level tracing to always store the most recent tracing data, discarding the oldest data when the maximum number of requests is reached.
To Enable Tracing for an application
1.Open your Web site’s Web.config file. If no Web.config file exists, create a new file in the root folder and copy the following into it:
2.Add a trace element as a child of the system.web element.
3.In the trace element, set the enabled attribute to true.
4.If you want trace information to appear at the end of the page that it is associated with, set the trace element’s pageOutput attribute to true. If you want tracing information to be displayed only in the trace viewer, set the pageOutput attribute to false.For example, the following application trace configuration collects trace information for up to 40 requests and allows browsers on computers other than the server of origin to display the trace viewer. Trace information is not displayed in individual pages.
58. What exactly happens when ASPX page is requested from Browser?
Ans. At its core, the ASP.NET execution engine compiles the page into a class, which derives from the code behind class (which in turn derives directly or indirectly from the Page class). Then it injects the newly created class into the execution environment, instantiates it, and executes it. ASP.NET, on the other hand, can accept code in any language that is compatible with the .NET framework, because it’s compiled down natively just like other code.
59.How can we kill a user session ?
Ans.The Abandon method destroys all the objects stored in a Session object and releases their resources.
If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.Syntax: Session.Abandon.
60.How do I send email message from ASP.NET?

Ans. The .NET Framework supplies a SMTP class that enables you to send a simple e-mail message. If you have to send an e-mail with added functionalities, you have to make use of the MailMessage class. With the help of this class, you can insert attachments, set priorities, and much more, very easily. You can also send HTML e-mail using this class.61. What are different IIS isolation levels?Ans. There are 3 IIS isolation levels.
* Low (IIS Process): ASP pages run in INetInfo.Exe, the main IIS process, therefore they are executed in-process. This is the fastest setting, and is the default under IIS4. The problem is that if ASP crashes, IIS crashes as well and must be restarted (IIS5 has a reliable restart feature that automatically restarts a server when a fatal error occurs).
* Medium (Pooled): In this case ASP runs in a different process, which makes this setting more reliable: if ASP crashes IIS won’t. All the ASP applications at the Medium isolation level share the same process, so you can have a web site running with just two processes (IIS and ASP process). IIS5 is the first Internet Information Server version that supports this setting, which is also the default setting when you create an IIS5 application. Note that an ASP application that runs at this level is run under COM+, so it’s hosted in DLLHOST.EXE (and you can see this executable in the Task Manager).
* High (Isolated): Each ASP application runs out-process in its own process space, therefore if an ASP application crashes, neither IIS nor any other ASP application will be affected. The downside is that you consume more memory and resources if the server hosts many ASP applications. Both IIS4 and IIS5 supports this setting: under IIS4 this process runs inside MTS.EXE, while under IIS5 it runs inside DLLHOST.EXE.

62.How do you deploy an ASP.NET application?
Ans.You can deploy an ASP.NET Web application using any one of the following three deployment options.
1.XCOPY Deployment
2.Using the Copy Project option in VS .NET
3.Deployment using VS.NET installer
(B) What’ is the sequence in which ASP.NET events are processed?
Following is the sequence in which the events occur:-
• Page_Init.
• Page Load.
• Control events
• Page- Unload event.
Page_init event only occurs when first time the page is started, but Page Load occurs in subsequent request of the page.

(B) In which event are the controls fully loaded?
Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event.5
(B) How can we identify that the Page is Post Back?
Page object has an “IsPostBack” property, which can be checked to know that is the page posted back.

(A) What is event bubbling?
Server controls like Data grid, Data List, and Repeater can have other child controls inside them. Example Data Grid can have combo box inside data grid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a data grid, data list, repeater), which passed to the page as “ItemCommand” event. As the child control send events to parent it is termed as event bubbling.
(B) How do we assign page specific attributes?
Page attributes are specified using the @Page directive.
(A) How do we ensure view state is not tampered?
Using the @Page directive and setting ‘EnableViewStateMac’ property to True.

(B) What is the use of @ Register directives?

@Register directive informs the compiler of any custom server control added to the page.

(B) What is the use of Smart Navigation property?
It’s a feature provided by ASP. NET to prevent flickering and redrawing when the page is posted back.

Note:- This is only supported for IE browser. Project is who have browser compatibility as requirements have to think some other ways of avoiding flickering.
(B) What is AppSetting Section in “Web.Config” file?
Web.config file defines configuration for a web project. Using “AppSetting” section, we can define user-defined values. Example below defined is “Connection String” section, which will be used through out the project for database connection.





(B) Where is View State information stored?
In HTML Hidden Fields.

(I) what is the use of @ Output Cache directive in ASP.NET.
It is used for caching. See more for Caching chapter.

(B) How can we create custom controls in ASP.NET?

User controls are created using .ASCX in ASP.NET. After .ASCX file is created you need to two things in order that the ASCX can be used in project:.


• Register the ASCX control in page using the


<%@ Register tag prefix="Accounting" Tag name="footer" Src="Footer.ascx" %>


• Now to use the above accounting footer in page you can use the below directive.



(B) How many types of validation controls are provided by ASP.NET?

There are six main types of validation controls:-

RequiredFieldValidator

It checks whether the control have any value. It is used when you want the control should not be empty.

RangeValidator

It checks if the value in validated control is in that specific range. Example TxtCustomerCode should not be more than eight lengths.

CompareValidator

It checks that the value in controls should match some specific value. Example Textbox TxtPie should be equal to 3.14.

RegularExpressionValidator

When we want the control, value should match with a specific regular expression.

CustomValidator

It is used to define User Defined validation.
Validation Summary
It displays summary of all current validation errors on an ASP.NET page.

Note: - It is rare that some one will ask step by step all the validation controls. Rather they will ask for what type of validation which validator will be used. Example in one of the interviews i was asked how will you display summary of all errors in the validation control...just uttered one word Validation summary.
(B) Can you explain “AutoPostBack”?

If we want the control to automatically post back in case of any event, we will need to check this attribute as true. Example on a Combo Box change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.

(B) How can you enable automatic paging in Data Grid?

Following are the points to be done in order to enable paging in Data grid:-
• Set the “Allow Paging” to true.
• In PageIndexChanged event set the current page index clicked.

Note: - The answers are very short, if you have implemented practically its just a revision. If you are fresher, just make sample code using Datagrid and try to implement this functionality.
(B) What is the use of “GLOBAL.ASAX” file?

It allows to execute ASP.NET application level events and setting application-level variables.

(B) What is the difference between “Web.config” and “Machine.Config”?

“Web.config” files apply settings to each web application, while “Machine.config” file apply settings to all ASP.NET applications.

(B) What is a SESSION and APPLICATION object?

Session object store information between HTTP requests for a particular user, while application object are global across users.

What’s the implicit name of the parameter that gets passed into the class’ set method? Value, and it’s datatype depends on whatever variable we’re changing.
How do you inherit from a class in C#? Place a colon and then the name of the base class.
Does C# support multiple inheritance? No, use interfaces instead.
When you inherit a protected class-level variable, who is it available to? Classes in the same namespace.
Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.
Describe the accessibility modifier protected internal. It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).
C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.
What’s the top .NET class that everything is derived from? System.Object.
How’s method overriding different from overloading? When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.
What does the keyword virtual mean in the method definition? The method can be over-ridden.
Can you declare the override method static while the original method is non-static? No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.
Can you override private virtual methods? No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.
Can you prevent your class from being inherited and becoming a base class for some other classes? Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.
Can you allow class to be inherited, but prevent the method from being over-ridden? Yes, just leave the class public and make the method sealed.
Can you inherit multiple interfaces? Yes, why not.
And if they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
What’s the difference between an interface and abstract class? In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.
How can you overload a method? Different parameter data types,different number of parameters , different order of parameters.
If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
What’s the difference between System.String and System.StringBuilder classes? System.String is immutable, System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
Is it namespace class or class namespace? The .NET class library is organized into namespaces. Each namespace contains a functionally related group of classes so natural namespace comes first.
***************************DATA BASE QUESTION **************************************
How do you return the top-N results of a query in Oracle? Why doesn't the obvious method work?
Most people think of using the ROWNUM pseudocolumn with ORDER BY. Unfortunately the ROWNUM is determined *before* the ORDER BY so you don't get the results you want. The answer is to use a subquery to do the ORDER BY first. For example to return the top-5 employees by salary:
SELECT * FROM (SELECT * FROM employees ORDER BY salary) WHERE ROWNUM < 5;
Which system table contains information on constraints on all the tables created ?
yes,
USER_CONSTRAINTS,
system table contains information on constraints on all the tables created

How to find out the database name from SQL*PLUS command prompt?
Select * from global_name;
This will give the datbase name which u r currently connected to.....

What is the difference between SQL and SQL Server ?
SQLServer is an RDBMS just like oracle,DB2 from Microsoft
whereas
Structured Query Language (SQL), pronounced "sequel", is a language that provides an interface to relational database systems. It was developed by IBM in the 1970s for use in System R. SQL is a de facto standard, as well as an ISO and ANSI standard. SQL is used to perform various operations on RDBMS.

What is diffrence between Co-related sub query and nested sub query?
Correlated subquery runs once for each row selected by the outer query. It contains a reference to a value from the row selected by the outer query.
Nested subquery runs only once for the entire nesting (outer) query. It does not contain any reference to the outer query row.
For example,
Correlated Subquery:
select e1.empname, e1.basicsal, e1.deptno from emp e1 where e1.basicsal = (select max(basicsal) from emp e2 where e2.deptno = e1.deptno)
Nested Subquery:
select empname, basicsal, deptno from emp where (deptno, basicsal) in (select deptno, max(basicsal) from emp group by deptno)
WHAT OPERATOR PERFORMS PATTERN MATCHING?
Pattern matching operator is LIKE and it has to used with two attributes
1. % and
2. _ ( underscore )
% means matches zero or more characters and under score means mathing exactly one character
1)What is difference between Oracle and MS Access?
2) What are disadvantages in Oracle and MS Access?
3) What are feratures&advantages in Oracle and MS Access?

Oracle's features for distributed transactions, materialized views and replication are not available with MS Access. These features enable Oracle to efficiently store data for multinational companies across the globe. Also these features increase scalability of applications based on Oracle.

What is cluster.cluster index and non cluster index ?
Clustered Index:- A Clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table may have only one clustered index.Non-Clustered Index:- A Non-Clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows in the disk. The leaf nodes of a non-clustered index does not consists of the data pages. instead the leaf node contains index rows.
How can i hide a particular table name of our schema?
you can hide the table name by creating synonyms.

e.g) you can create a synonym y for table x
create synonym y for x;
What is difference between DBMS and RDBMS?
The main difference of DBMS & RDBMS is
RDBMS have Normalization. Normalization means to refining the redundant and maintain the stablization.
the DBMS hasn't normalization concept.

What are the advantages and disadvantages of primary key and foreign key in SQL?
Primary key
Advantages
1) It is a unique key on which all the other candidate keys are functionally dependent
Disadvantage
1) There can be more than one keys on which all the other attributes are dependent on.
Foreign Key
Advantage
1)It allows refrencing another table using the primary key for the other table
Which date function is used to find the difference between two dates?
datediff

for Eg: select datediff (dd,'2-06-2007','7-06-2007')
output is 5
1.       What is a CO-RELATED SUBQUERY
A CO-RELATED SUBQUERY is one that has a correlation name as table or view designator in the FROM clause of the outer query and the same correlation name as a qualifier of a search condition in the WHERE clause of the subquery.
2.           eg
3.                SELECT  field1 from table1 X
4.                WHERE  field2>(select avg(field2) from table1 Y
5.                                                  where
                                       field1=X.field1);


(The subquery in a correlated subquery is revaluated for every row of the table or view named in the outer query.)


6.       What are various joins used while writing SUBQUERIES
Self join-Its a join foreign key of a table references the same table.

Outer Join--Its a join condition used where One can query all the rows of one of the tables in the join condition even though they don't satisfy the join condition.

Equi-join--Its a join condition that retrieves rows from one or more tables in which one or more columns in one table are equal to one or more columns in the second table.


7.       What are various constraints used in SQL
NULL
NOT NULL
CHECK
DEFAULT


8.       What are different Oracle database objects
TABLES
VIEWS
INDEXES
SYNONYMS
SEQUENCES
TABLESPACES etc


9.       What is difference between Rename and Alias
Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.


10.    What is a view
A view is stored procedure based on one or more tables, its a virtual table.


11.    What are various privileges that a user can grant to another user
SELECT
CONNECT
RESOURCE


12.    What is difference between UNIQUE and PRIMARY KEY constraints
A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.


13.    Can a primary key contain more than one columns
Yes


14.    How you will avoid duplicating records in a query
By using DISTINCT


15.    What is difference between SQL and SQL*PLUS
SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.


16.    Which datatype is used for storing graphics and images
LONG RAW data type is used for storing BLOB's (binary large objects).


17.    How will you delete duplicating rows from a base table
DELETE FROM table_name A WHERE rowid>(SELECT min(rowid) from table_name B where B.table_no=A.table_no);

CREATE TABLE new_table AS SELECT DISTINCT * FROM old_table;

DROP old_table RENAME new_table TO old_table DELETE FROM table_name A WHERE rowid NOT IN (SELECT MAX(ROWID) FROM table_name GROUP BY column_name)




18.    What is difference between SUBSTR and INSTR
SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDE INSTR provides character position in which a pattern is found in a string.

eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-')


19.    There is a string '120000 12 0 .125' ,how you will find the position of the decimal place
INSTR('120000 12 0 .125',1,'.') output 13


20.    There is a '%' sign in one field of a column. What will be the query to find it.
'\' Should be used before '%'.


21.    When you use WHERE clause and when you use HAVING clause
HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause The WHERE clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before GROUP BY clause if it is used.


22.    Which is more faster - IN or EXISTS
EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.


23.    What is a OUTER JOIN
Outer Join--Its a join condition used where you can query all the rows of one of the tables in the join condition even though they dont satisfy the join condition.


24.    How you will avoid your query from using indexes
SELECT * FROM emp Where emp_no+' '=12345;

i.e you have to concatenate the column name with space within codes in the where condition.

SELECT /*+ FULL(a) */ ename, emp_no from emp where emp_no=1234;

i.e using HINTS
25.    What is a pseudo column. Give some examples
It is a column that is not an actual column in the table.

eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL.

Suppose customer table is there having different columns like customer no, payments.What will be the query to select top three max payments.

SELECT customer_no, payments from customer C1 WHERE 3<=(SELECT COUNT(*) from customer C2 WHERE C1.payment <= C2.payment)


26.    What is the purpose of a cluster.
Oracle does not allow a user to specifically locate tables, since that is a part of the function of the RDBMS. However, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for faster retrieval than if the table placement were left to the RDBMS.


27.    What is a cursor.
Oracle uses work area to execute SQL statements and store processing information PL/SQL construct called a cursor lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than one row in a Pl/SQl block.


28.    Difference between an implicit & an explicit cursor.
PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including quries that return only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop.

Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.


29.    What are cursor attributes
%ROWCOUNT
%NOTFOUND
%FOUND
%ISOPEN


30.    What is a cursor for loop.
Cursor For Loop is a loop where oracle implicitly declares a loop variable, the loop index that of the same record type as the cursor's record.


31.    Difference between NO DATA FOUND and %NOTFOUND
NO DATA FOUND is an exception raised only for the SELECT....INTO statements when the where clause of the querydoes not match any rows. When the where clause of the explicit cursor does not match any rows the %NOTFOUND attribute is set to TRUE instead.


32.    What a SELECT FOR UPDATE cursor represent.
SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT] The processing done in a fetch loop modifies the rows that have been retrieved by the cursor.
A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.


33.    What 'WHERE CURRENT OF ' clause does in a cursor.
34.     LOOP
35.                               SELECT  num_credits  INTO  v_numcredits  FROM classes
36.                               WHERE  dept=123 and course=101;
37.                               UPDATE  students
38.                               SET current_credits=current_credits+v_numcredits
39.                               WHERE  CURRENT OF  X;
40.                               END  LOOP
41.                               COMMIT;
                          END;
 


42.    What is use of a cursor variable? How it is defined.
A cursor variable is associated with different statements at run time, which can hold different values at run time. Static cursors can only be associated with one run time query. A cursor variable is reference type(like a pointer in C).
Declaring a cursor variable: TYPE type_name IS REF CURSOR RETURN return_type type_name is the name of the reference type,return_type is a record type indicating the types of the select list that will eventually be returned by the cursor variable.


43.    What should be the return type for a cursor variable.Can we use a scalar data type as return type.
The return type for a cursor must be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be used. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE


44.    How you open and close a cursor variable.Why it is required.
OPEN cursor variable FOR SELECT...Statement CLOSE cursor variable In order to associate a cursor variable with a particular SELECT statement OPEN syntax is used.In order to free the resources used for the query CLOSE statement is used.


45.    How you were passing cursor variables in PL/SQL 2.2.
In PL/SQL 2.2 cursor variables cannot be declared in a package.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2.2,the only means of passing a cursor variable to a PL/SQL block is via bind variable or a procedure parameter.


46.    Can cursor variables be stored in PL/SQL tables.If yes how.If not why.
No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.


47.    Difference between procedure and function.
Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.


48.    What are different modes of parameters used in functions and procedures.
IN
OUT
INOUT


49.    What is difference between a formal and an actual parameter
The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters


50.    Can the default values be assigned to actual parameters.
Yes


51.    Can a function take OUT parameters.If not why.
No.A function has to return a value,an OUT parameter cannot return a value.


52.    What is syntax for dropping a procedure and a function .Are these operations possible.
53. 
54.               Drop Procedure procedure_name
55.               Drop Function function_name
 


56.    What are ORACLE PRECOMPILERS.
Using ORACLE PRECOMPILERS ,SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA.
The Precompilers are known as Pro*C,Pro*Cobol,... This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language.
The prcompiler translates the embedded SQL and pl/sql ststements into calls to the precompiler runtime library.The output must be compiled and linked with this library to creater an executable.


57.    What is OCI. What are its uses.
Oracle Call Interface is a method of accesing database from a 3GL program. Uses--No precompiler is required,PL/SQL blocks are executed like other DML statements.
58.                      The OCI library provides
59.                     -functions to parse SQL statemets
60.                     -bind input variables
61.                     -bind output variables
62.                     -execute statements
63.                     -fetch the results
 


64.    Difference between database triggers and form triggers.
a) Data base trigger(DBT) fires when a DML operation is performed on a data base table.Form trigger(FT) Fires when user presses a key or navigates between fields on the screen
b) Can be row level or statement level No distinction between row level and statement level.
c) Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as variables in forms.
d) Can be fired from any session executing the triggering DML statements. Can be fired only from the form that define the trigger.
e) Can cause other database triggers to fire.Can cause other database triggers to fire,but not other form triggers.


65.    What is an UTL_FILE.What are different procedures and functions associated
with it. UTL_FILE is a package that adds the ability to read and write to operating system files Procedures associated with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.


66.    Can you use a commit statement within a database trigger.
No


67.    What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function?
1,000,000


 



 

Previous
Next Post »
Thanks for your comment