Tuesday, November 15, 2011

Six different validation server controls are available for ASP.NET:


  • RequiredFieldValidator
  • CompareValidator
  • RangeValidator
  • RegularExpressionValidator
  • CustomValidator
  • ValidationSummary

Friday, November 4, 2011

SQL HAVING Clause

Having clause is used to filter data based on the group functions. This is similar to WHERE condition but is used with group functions. Group functions cannot be used in WHERE Clause but can be used in HAVING clause.
For Example: If you want to select the department that has total salary paid for its employees more than 25000, the sql query would be like;
SELECT dept, SUM (salary)
FROM employee
GROUP BY dept
HAVING SUM (salary) > 25000

The output would be like:
dept salary
-------------              -------------
Electronics                  55000
Aeronautics                  35000
InfoTech                  30000
When WHERE, GROUP BY and HAVING clauses are used together in a SELECT statement, the WHERE clause is processed first, then the rows that are returned after the WHERE clause is executed are grouped based on the GROUP BY clause. Finally, any conditions on the group functions in the HAVING clause are applied to the grouped rows before the final output is displayed.

Thursday, November 3, 2011

Difference between method overriding and overloading

there is big difference between both:
see following example

When overriding, you change the method behavior for a derived class.
e.g Clas A
{
Virtual void hi(int a)
{
}
}

Class B:A
{
public overrid void hi(int a)
{

}
}

Overloading simply involves having a method with the same name within the class.

Example for Over loading

Class A
{
class a()

{

}
class a(int a)
{
}
}

Wednesday, November 2, 2011

What is the difference between a class and a structure?

Class:

  1. A class is a reference type.
  2. The members of a class are private by default.
  3. While instantiating a class, CLR allocates memory for its instance in heap.
  4. Classes support inheritance.
  5. Variables of a class can be assigned as null.
  6. Class can contain constructor/destructor.

Structure:
  1. A structure is a value type.
  2. The members of a structure are public by default
  3. In structure, memory is allocated on stack.
  4. Structures do not support inheritance.
  5. Structure members cannot have null values.
  6. Structure does not require constructor/destructor and members can be initialiazed automatically.

What is CLR, CTS, CLS in .NET?

Common Language Runtime (CLR)
One of the most important component of .NET framework is CLR, also known as runtime. It provides functionalities like
  1. Memory Management
  2. Exception handling
  3. Debugging
  4. Code Access Security (CAS)
  5. Thread Execution
  6. Compilation
The runtime manages the execution of code. It also enables you to develop application in the language of your choice, such as C#, Visual Basic and Visual C++. You can also refer the class library and other components that are written in different languages supported by .NET framework.
Common Type System (CTS)
The CTS specifies certain guidelines for declaring, using, and managing types at runtime. The functions performed by the CTS are as follows:
  1. Cross-language communication, type safety, and high performance execution of code.
  2. Object-oriented model for implementation of different programming languages.
  3. Guidelines for different languages to follow, ensuring proper interaction between objects implemented in different programming languages.
The CTS can be classified as Value and Reference types.
Common Language Specification (CLS)
The CLS consists of a set of basic language features that are required by many applications to communicate with other objects, irrespective of the language in which they are implemented. The CLS rules define a subset of the common type system. These objects must expose only those features that are common to all the languages they need to interact with. The components which adhere to these features are said to be CLS compliant components. In simple words it facilitates cross-language interoperability.



CLR - CTS - CLS
The .NET Framework provides a runtime environment called the Common Language Runtime or CLR (similar to the Java Virtual Machine or JVM in Java), which handles the execution of code and provides useful services for the implementation of the program.
The Common Language Runtime is the underpinning of the .NET Framework. CLR takes care of code management at program execution and provides various beneficial services such as memory management, thread management, security management, code verification, compilation, and other system services. The managed code that targets CLR benefits from useful features such as cross-language integration, cross-language exception handling, versioning, enhanced security, deployment support, and debugging.
Common Type System (CTS) describes how types are declared, used and managed in the runtime and facilitates cross-language integration, type safety, and high performance code execution.
The Common Language Specification (CLS) is an agreement among language designers and class library designers to use a common subset of basic language features that all languages have to follow.

what is difference between class and object?

Class is templet for an object.
Object is an instance of a class.

Monday, October 24, 2011

What is the basic difference between ASP and ASP.NET?

The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).

Thursday, October 20, 2011

Good link for .net Interview Quetions & Answers

http://indiabix.com/

http://p2p.wrox.com/net-framework-2-0/31636-dot-net-interview-questions-answers.html

Tuesday, October 18, 2011

Flip Horizontally in asp.net with c#

.aspx
--------
   <asp:Button ID="btflip" runat="server" Text="flip" onclick="btflip_Click" />

 .aspx.cs
---------

 protected void btflip_Click(object sender, EventArgs e)
    {
        // get the full path of image url
        string path = Server.MapPath(Image1.ImageUrl);

        // creating image from the image url
        System.Drawing.Image i = System.Drawing.Image.FromFile(path);

        // rotate Image 180' Degree
        i.RotateFlip(RotateFlipType.Rotate180FlipY);

        // save it to its actual path
        i.Save(path);

        // release Image File
        i.Dispose();

        // Set Image Control Attribute property to new image(but its old path)
        Image1.Attributes.Add("ImageUrl", path);

    }



Rotation in asp.net with c#

lib
----
using System.Drawing;


Default.aspx
-------------

 <asp:Image ID="Image1" runat="server" Height="297px"
            ImageUrl="~/images/Winter.jpg" Width="343px" />

<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="Rotate Image" />


Default.aspx.cs
----------------

   protected void Button1_Click(object sender, EventArgs e)
    {
        // get the full path of image url
        string path = Server.MapPath(Image1.ImageUrl);

        // creating image from the image url
        System.Drawing.Image i = System.Drawing.Image.FromFile(path);

        // rotate Image 90' Degree
        i.RotateFlip(RotateFlipType.Rotate90FlipXY);

        // save it to its actual path
        i.Save(path);

        // release Image File
        i.Dispose();

        // Set Image Control Attribute property to new image(but its old path)
        Image1.Attributes.Add("ImageUrl", path);

    }

Sunday, May 1, 2011

Everything can change in the blink of an eye , but don't worry : God never Blinks ....  

How to work Session Variable??

I guess Session Variable works as under.


·        You can use the session end of the Application or Website. Only once you can create the session for the one Application or Website. Once you create a session variable you can use that session on randomly page into the whole Application or Website.

·        Once you close (eg :-  logout) with the  Application or Website than your session will be expired(close).