Wednesday, September 17, 2008

Fun with Javascript


Some basic validations using JavaScript


U might got tired of using server side validation which will take so much time to execute and bore the user, so here is an example of basic validations.

function Validationofusername()
{
//For User Name
var UserName=document.getElementById("<%=txtUserName.ClientID %>").value;
var UserNAmeLen=document.getElementById("<%=txtUserName.ClientID %>").value.length;
if(UserName=="")
{
alert('Enter User Name');
document.getElementById("<%=txtUserName.ClientID %>").focus();
return false;
}
if(UserName.length<4 || UserName.length>20)
{
alert('Min. Length of User Name is 4 and Max. Length 20\n Current Length='+UserNAmeLen);
document.getElementById("<%=txtUserName.ClientID %>").focus();
return false;
}
var ExpUserName=/^[A-Za-z0-9/.@-_$#%&*()]+$/;
if(!UserName.match(ExpUserName))
{
alert('UserName Contains Invalid Characters');
document.getElementById("<%=txtUserName.ClientID%>").focus();
return false;
}
}

Which will checks requiredfield validator and the length should be in the range of 4 to 20 and allows only some special characters


Writing Regular expressions

/^[A-Za-z0-9/.@-_$#%&*()]+$/;

For example take the above case

/ means start from the string

+$/ end of string

[ ] indicates allowble characters

A-Z means all uppercase

a-z all lowercase

0-9 all numerics

Then special chars whatever we want to allow

Caution:

Special chars should be given in sequence like

~!@#$%^&*()_+

Means start from the left to right

Some browsers don’t support + sign so be careful while using that


cheat for your email expression


Just add an regular expression validation and then go for email

There u can see the regular expression ,

Just ctrl+c and ctrl+v

It may look like this

var EmailExp=/^(\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)+$/;


website url validation


var WebsiteExp=/^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}[0-9A-Za-z\.\-]*\.[0-9A-Za-z\.\-]*$/;


Phone number

U have to allow only numerics so

Var phoneEXp=/^[0-9]+$/;


For check box validation

if(document.getElementById("<%=chkID.ClientID%>").checked==false)
{
alert('You must Accept Terms and Conditions');
document.getElementById("<%=chkChecked.ClientID%>").focus();
return false;
}


For dropdownlist validation

if(document.getElementById("<%=ddlCity.ClientID%>").selectedIndex==0)
{
alert('Select City');
document.getElementById("<%=ddlCity.ClientID%>").focus();
return false;
}


For listbox validation

if(document.getElementById("<%=lbKeySkills.ClientID%>").options[0].selected)
{
alert('Not allowed to select First option in Key Skills');
document.getElementById("<%=lbKeySkills.ClientID%>").focus();
return false;
}
var i=document.getElementById("<%=lbKeySkills.ClientID%>").options.length;

var Count=0;
for(var j=0;j {
if(document.getElementById("<%=lbKeySkills.ClientID%>").options[j].selected)
{
Count=Count+1;
}
}
if(Count>3)
{
alert('Not allowed to select more than 3 options');
document.getElementById("<%=lbKeySkills.ClientID%>").focus();
return false;
}




For date validation

if(document.getElementById("<%=txtDOB.ClientID %>").value == "")
{
alert('Please Enter Date');
document.getElementById("<%=txtDOB.ClientID %>").focus();
return false;
}
if(document.getElementById("<%=txtDOB.ClientID %>").value!="")
{
var dateStr=document.getElementById("<%=txtDOB.ClientID %>").value;
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null)
{
alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
return false;
}

month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12)
{ // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31)
{
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31)
{
alert("Month "+month+" doesn't have 31 days!")
return false;
}

if (month == 2)
{ // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap))
{
alert("February " + year + " doesn't have " + day + " days!");
return false;
}
}
}




To trim the string from left&right


function TrimString(inputstring) {
inputstring= inputstring.replace( /^\s+/g, "" ); // strip starting
return inputstring.replace( /\s+$/g, "" ); // strip ending
}



Making the first letter as capital of the given string



function InitialCaps(inputstring) {
inputstring= inputstring.toLowerCase();
inputstring= inputstring.substr(0, 1).toUpperCase() + theString.substring(1, inputstring.length);

var i = 0;
var j = 0;
while((j = inputstring.indexOf(" ", i)) && (j != -1)) {
inputstring= inputstring.substring(0, j + 1) + inputstring.substr(j + 1, 1).toUpperCase() + inputstring.substring(j + 2, inputstring.length);
i = j+1;
}
return inputstring;
}



Saturday, September 13, 2008

reading word content into the text box

I think may be u tried all interop combinations to read word document ,
But where everything fails is eveytime u instantiate word app a new process will be created under asp.net account but whenever we are closing the document the process wont stop that’s y a loop will be formed and whenever we are running the same application we cant instantiate another instance for wordapp

By placing this code it is working fine for me (upto now)

So have a look on this





try
{
string strfilePath = ds.Tables[0].Rows[0]["ResumePath"].ToString();

Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object nullobj = System.Reflection.Missing.Value;
object FileObj = strfilePath;
Microsoft.Office.Interop.Word.Document Doc = WordApp.Documents.Open(ref FileObj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj);
Microsoft.Office.Interop.Word.Document Doc1 = WordApp.ActiveDocument;
string m_content = Doc1.Content.Text;
txtResume.Text = m_content;
Doc.Close(ref nullobj, ref nullobj, ref nullobj);
WordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
WordApp = null;
Doc = null;
Process p = Process.GetCurrentProcess();

p.Close();
}
catch
{
throw;
}

Tuesday, April 1, 2008

Interview questions

Explain the access specifiers Public, Private, Protected, Friend, Internal, Default
The main purpose of using access specifiers is to provide security to the applications. The availability (scope) of the member objects of a class may be controlled using access specifiers.

1. PUBLIC
As the name specifies, it can be accessed from anywhere. If a member of a class is defined as public then it can be accessed anywhere in the class as well as outside the class. This means that objects can access and modify public fields, properties, methods.


2. PRIVATE
As the name suggests, it can't be accessed outside the class. Its the private property of the class and can be accessed only by the members of the class.

3. FRIEND/INTERNAL
Friend & Internal mean the same. Friend is used in VB.NET. Internal is used in C#. Friends can be accessed by all classes within an assembly but not from outside the assembly.

4. PROTECTED
Protected variables can be used within the class as well as the classes that inherites this class.

5. PROTECTED FRIEND/PROTECTED INTERNAL
The Protected Friend can be accessed by Members of the Assembly or the inheriting class, and ofcourse, within the class itself.

6. DEFAULT
A Default property is a single property of a class that can be set as the default. This allows developers that use your class to work more easily with your default property because they do not need to make a direct reference to the property. Default properties cannot be initialized as Shared/Static or Private and all must be accepted at least on argument or parameter. Default properties do not promote good code readability, so use this option sparingly
What is the difference between Overriding and Shadowing?
Both Overriding and Shadowing are ways to alter the behaviour of members of a base class. Shadowing is a VB.NET concept. In C#, this concept is called Hiding, though there is a difference between the two.

When we do shadowing, we provide a new implementation to the base class member without overriding it. We may shadow a base class member in a derived class, by using the keyword shadows. The access level, return type, and the signature (means the datatypes of the arguments passed & the order of the types) of the derived class members which are shadowed, may differ from the base class.

In C#, we may achieve shadowing using the keyword new. However, when Hiding in C#, the access level, the signature, return type of the derived class must be same as the base class.

Overriding is the concept of providing a new implementation of derived class member as compared to its based class. In VB.NET, we do overriding using the overrides keyword, while in C#, overriding is achieved using the override keyword. For a class member to be overridable, we use the keyword virtual while defining it (in C#), and we use the keyword overridable (in VB.NET), though if we leave out specifying the overridable keyword, the member is overridable by default.

Whats the difference between a class and an object?
In any object Oriented language, an object is the backbone of everything that we see. A class is a blueprint that describes how an instance of it (object) will behave. To create a class, we define it in a "Code File", with an extension *.cs or *.vb. We make use of the keyword class.
Example
Lets create a class named Laptop
public class Laptop
{
private string sbrand;
public Laptop() {}
public Laptop(string name)
{
sbrand = name;
}
}

From our code that references this class, we write...
Laptop lp = new Laptop("Lenovo"); //Passing a variable to the class constructor
Once the class object is created, the object may be used to invoke the member functions defined within the class. We may allocate any number of objects using the new keyword. The new keyword returns a reference to an object on the heap. This reference is not to the actual object itself. The variable being refered is stored on a stack for usage in the application. When we allocate an object to a heap, its managed by the .NET runtime. The garbage collector takes care of the object by removing it from the heap, when it is no longer reachable by any part of the code.
What is the difference between a Class Library and a Namespace?
Class Library is another major entity of the .NET Framework (the other being the CLR). This library gives the program access to runtime environment. The class library consists of lots of prewritten code that all the applications created in .NET will use. The code for all the elements like forms, controls actually comes from the class library. The main class library in .NET is mscorlib.dll. This library contains a large number of core types that encapsulate a wide variety of common tasks. When a .NET application, there is automatic access to this library. We may view the class libraries provided by the .NET Framework by seeing the Global Assembly Cache (Go to C:\Windows\Assembly OR C:\Winnt\Assembly).

Namespace is a grouping of related types contained in an assembly. For example, the System.Drawing namespace consists of classes, methods that are grouped together to achieve similar tasks.
Note that a single assembly like mscorlib.dll may contain any number of namespaces. In fact, namespaces may be nested (means a namespace within a namespace) to arrange classes in a hierarchical fashion.

Also note that any language, that works on the .NET environment, targets the same set of namespaces & types provided by the .NET framework.
What is the difference between String and StringBuilder?
Both String and StringBuilder are classes used to handle strings.

The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".

When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.

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

Both "Server" and "Response" are objects of ASP.NET. Server.Transfer and Response.Redirect both are used to transfer a user from one page to another. But there is an underlying difference.
//Usage of Server.Transfer & Response.Redirect
Server.Transfer("Page2.aspx");
Response.Redirect("Page2.aspx");
The Response.Redirect statement sends a command back to the browser to request the next page from the server. This extra round-trip is often inefficient and unnecessary, but this established standard works very well. By the time Page2 is requested, Page1 has been flushed from the server’s memory and no information can be retrieved about it unless the developer explicitly saved the information using some technique like session, cookie, application, cache etc.

The more efficient Server.Transfer method simply renders the next page to the browser without an extra round trip. Variables can stay in scope and Page2 can read properties directly from Page1 because it’s still in memory. This technique would be ideal if it wasn’t for the fact that the browser is never notified that the page has changed. Therefore, the address bar in the browser will still show “Page1.aspx” even though the Server.Transfer statement actually caused Page2.aspx to be rendered instead. This may occasionally be a good thing from a security perspective, it often causes problems related to the browser being out of touch with the server. Say, the user reloads the page, the browser will request Page1.aspx instead of the true page (Page2.aspx) that they were viewing. In most cases, Response.Redirect and Server.Transfer can be used interchangeably. But in some cases, efficiency or usability may be the deciding factor in choosing.
What is the difference between Server.Transfer and Server.Execute?
Both Server.Transfer and Server.Execute were introduced in Classic ASP 3.0 (and still work in ASP.NET).

When Server.Execute is used, a URL is passed to it as a parameter, and the control moves to this new page. Execution of code happens on the new page. Once code execution gets over, the control returns to the initial page, just after where it was called. However, in the case of Server.Transfer, it works very much the same, the difference being the execution stops at the new page itself (means the control is'nt returned to the calling page).

In both the cases, the URL in the browser remains the first page url (does'nt refresh to the new page URL) as the browser is'nt requested to do so.

What is the difference between ExecuteScalar and ExecuteNonQuery? What is ExecuteReader?
ExecuteScalar - Returns only one value after execution of the query. It returns the first field in the first row. This is very light-weight and is perfect when all your query asks for is one item. This would be excellent for receiving a count of records (Select Count(*)) in an sql statement, or for any query where only one specific field in one column is required.

ExecuteNonQuery - This method returns no data at all. It is used majorly with Inserts and Updates of tables. It is used for execution of DML commands.
Example:
SqlCommand cmd = new SqlCommand("Insert Into t_SomeTable Values('1','2')",con);
//note that con is the connection object
con.Open();
cmd.ExecuteNonQuery();
//The SQL Insert Statement gets executed
ExecuteReader - This method returns a DataReader which is filled with the data that is retrieved using the command object. This is known as a forward-only retrieval of records. It uses our SQL statement to read through the table from the first to the last record.
What is the difference between a DataReader and Dataset in ADO.NET?
A DataReader works in a connected environment, whereas DataSet works in a disconnected environment.

A DataReader object represents a forward only, read only access to data from a source. It implements IDataReader & IDataRecord interfaces. For example, The SQLDataReader class can read rows from tables in a SQL Server data source. It is returned by the ExecuteReader method of the SQLCommand class, typically as a result of a SQL Select statement. The DataReader class' HasRows property can be called to determine whether the DataReader retrieved any rows from the source. This can be used before using the Read method to check whether any data has been retrieved.
Example
Dim objCmd as New SqlCommand("Select * from t_Employees", objCon)
objCon.Open()
Dim objReader as SqlDataReader
objReader = objCom.ExecuteReader(CommandBehavior.CloseConnection)
If objReader.HasRows = True then
Do While objReader.Read()
ListBox1.Items.Add(objReader.GetString(0) & vbTab & objReader.GetInt16(1))
Loop
End If
objReader.Close()
(NOTE: XmlReader object is used for Forward only Read only access of XML).

A DataSet represents an in-memory cache of data consisting of any number of inter-related DataTable objects. A DataTable object represents a tabular block of in-memory data. Further, a DataRow represents a single row of a DataTable object. A Dataset is like a mini-database engine, but its data is stored in the memory. To query the data in a DataSet, we can use a DataView object.

Example

Dim objCon as SqlConnection = New SqlConnection("server=(local);database=NameOfYourDb;user id=sa; password=;)
Dim da as New SqlDataAdapter
Dim ds as DataSet = New DataSet
da.SelectCommand.Connection = objCon 'The Data Adapter manages on its own, opening & closing of connection object
da.SelectCommand.CommandText = "Select * from t_SomeTable"
da.Fill(ds,"YourTableName")

Suppose you want to bind the data in this dataset to a gridview

Gridview1.DataSource = ds
Gridview1.DataMember = "YourTableName"
Gridview1.Databind()
What is the difference between System.Array.CopyTo and System.Array.Clone in .NET?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy.
What is .NET?
.NET - is the Microsoft Web services strategy to connect information, people, systems, and devices through software. Integrated across the Microsoft platform, .NET technology provides the ability to quickly build, deploy, manage, and use connected, security-enhanced solutions with Web services. .NET-connected solutions enable businesses to integrate their systems more rapidly and in a more agile manner and help them realize the promise of information anytime, anywhere, on any device. Reference
Which languages can be used to program in .NET?
Microsoft provides these languages for programming .NET - C#, VB.NET, JS.NET, C++.NET.

C++.NET may be used as a Managed Code Language by using managed extensions. This is done using an _gc postfix. A managed C++ class can inherit from VB.NET classes, C# classes, JS.NET classes. A managed class can inherit from only one class. .NET does'nt allow multiple inheritance in managed classes.



Any Language that has a compiler that can compile the language code to MSIL is a .NET compliant language.

Below is an alphabetical list of languages supported by .NET

APL - It is a language for describing procedures in the processing of information. It is a very powerful language. It may be used to describe mathematical procedures.

C++ - A widely known language. One of the oldest Object Oriented Languages, an advanced version of the C language. Microsoft has its own Visual C++ compiler that includes special tools and libraries for development on Windows platform. C++ is an object-oriented programming language that is viewed by many as the best language for creating large-scale applications. C++ is a superset of the C language.

C# - Pronounced C Sharp. It is a complete Object-Oriented programming language from Microsoft built into the .NET Framework. First created in the late 1990’s was part of Microsoft’s whole .NET strategy.

COBOL - Expanded as Common Business Oriented Language. It is a widely used high level language for developing Business Applications.

Component Pascal - Its a Pascal derived programming language for development of programming components.

Eiffel - It is an Object-Oriented programming language which emphasizes the production of robust software.

Forth - It is both a programming language & a programming environment. It supports shell programming to a high level.

Fortran - Stands for Formula Translator. Its a high level programming language used for scientific computations. It supports plenty of compact notations.

Haskell - It is a standardized functional programming language with non-strict semantics, named after the logician Haskell Curry. It was created by a committee formed in the 1980s for the express purpose of defining such a language.The latest semi-official language standard is Haskell 98, intended to specify a minimal, portable version of the language for teaching and as a base for future extensions.

Java - It is an object-oriented programming language developed initially by James Gosling and colleagues at Sun Microsystems. The language, initially called Oak (named after the oak trees outside Gosling's office), was intended to replace C++, although the feature set better resembles that of Objective C. Java should not be confused with JavaScript, which shares only the name and a similar C-like syntax. Sun Microsystems currently maintains and updates Java regularly.

Microsoft JScript - A scripting language developed by Microsoft to enable Web page designers to design interactive sites. Although it shares many of the features and structures of the full Java language, it was developed independently. Jscript can interact with HTML source code, better enabling Web authors to spice up their sites with dynamic content.

Mercury - Mercury is a functional/logical programming language based on Prolog, but more useful for real-world programming.

Mondrian - It is a simple functional scripting language for Internet applications. It is a functional language specifically designed to inter-operate with other languages in an OO environment. Current versions of Mondrian run on .NET. Mondrian also supports ASP.NET, allowing you to embed functional language code in web pages along with C# code.

Oberon - It is a programming language very much like Modula-2 in syntax but with several interesting features. It's based on OOP concepts and also provides a Windows-based GUI.

Pascal - A high-level, highly structured, general-purpose programming language. Named after Blaise Pascal.

Perl - Stands for Practical Extraction and Report Language. It is a language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information.

Python - It is an interpreted, interactive, Object-Oriented programming language. Python combines remarkable power with very clear syntax. It has modules, classes, exceptions, very high level dynamic data types, and dynamic typing.

RPG - Stand for Report Program Generator. It is used for generation of reports from data files, including matching record and sub-total reports. RPG is one of the few languages created for punch card machines that is still in common use today.

Scheme - It is a statically scoped programming language. It was designed to have an exceptionally unambigous and simple semantics and few different ways to form expressions. A vast variety of programming paradigms, including imperative, functional, and message passing styles, find convenient expression in Scheme.

Smalltalk - It is a simple language that uses a simple sub set of human languages, nouns and verbs. Smalltalk was the first, and remains one of the few, pure object systems, which simply means that everything in a Smalltalk program is an object.

Standard ML - It is a safe, modular, strict, functional, polymorphic programming language with compile-time type checking and type inference, garbage collection, exception handling, immutable data types and updatable references, abstract data types, and parametric modules.

Microsoft Visual Basic - Most widely used language in the world today! Used for developing Windows based Applications, Windows Services, Remoting Applications, Web Services and Web Applications(using ASP.NET).
Which tools can be used for .NET Development?
The .NET Framework SDK is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development.

SharpDevelop is a free IDE for C# and VB.NET.

Microsoft Visual Studio Express editions are cut-down versions of Visual Studio, for hobbyist or novice developers and are available for FREE Download at Microsoft site. Note that .NET 2.0 Framework gets downloaded along with Visual Studio Express & All versions above Visual Studio Express. Download Visual Studio Express

There are different versions for C#, VB, web development etc. Microsoft Visual Studio Standard 2005 is around $300, or $200 for the upgrade.

Microsoft VIsual Studio Professional 2005 is around $800, or $550 for the upgrade. At the top end of the price range are the Microsoft Visual Studio Team Edition for Software Developers 2005 with MSDN Premium and Team Suite editions. Visual Web Developer Express is available as a free download.

The next version of Visual Studio, code named Orcas, Beta 1 has been released as a Beta Version and is available for download. Download Orcas
Explain CLI, CIL, CTS, Metadata, CLS, IL and VES in .NET
CLI - Common Language Infrastructure. Microsoft has a piece of shared source, its the public implementation of ECMA Common Language Infrastructure. This shared code is code-named "Rotor". It has around 3 million lines of code. Those who are interesed in development of a language that targets the .NET Framework, may extensively make use of this CLI. The following topics are covered in the Shared Source CLI :

* The CLI type system
* Component packing & assemblies
* Type Loading & JIT Compilatino
* Managed code & Execution Engine (CLR)
* Description of Garbage Collection process & memory management
* The Platform Adaptation Layer (PAL): a portability layer for Win32®, Mac OS® X, and FreeBSD

Its been written by the Microsoft Team that has developed the .NET Framework.

Note: A compiled managed assembly is comprised of IL, Metadata and Manifest.

CIL Stands for Common Intermediate Language. Its actually a low level human readable language implementation of CLI. All .NET-aware languages compile the source oode to an intermediate language called Common Intermediate Language using the language specific compiler. It is also possible to build .NET assemblies direclty using CIL using the ilasm.exe compiler. This compiler is shipped along with the .NET Framework 2.0 SDK. CIL is the only language that allows access to each aspect of the CTS. CIL is the definition of the fundamentals of the .NET framework.

CTS - stands for Common Type Specification. It is at the core of .NET Framework's cross-language integration, type safety, and high-performance code execution. It defines a common set of types that can be used with many different language syntaxes. Each language (C#, VB.NET, Managed C++, and so on) is free to define any syntax it wishes, but if that language is built on the CLR, it will use at least some of the types defined by the CTS.

Metadata - is code that describes the compiled IL. A .NET language compiler will generate the metadata and store this in the assembly containing the CIL. Metadata describes all class members and classes that are defined in the assembly, and the classes and class members that the current assembly will call from another assembly. The metadata for a method contains the complete description of the method, including the class (and the assembly that contains the class), the return type and all of the method parameters. When the CLR executes CIL it will check to make sure that the metadata of the called method is the same as the metadata that is stored in the calling method. This ensures that a method can only be called with exactly the correct number of parameters and exactly the correct parameter types.

CLS - Common Language Specification. A type that is CLS compliant, may be used across any .NET language. CLS is a set of language rules that defines language standards for a .NET language and types declared in it. While declaring a new type, if we make use of the [CLSCompliant] attribute, the type is forced to conform to the rules of CLS.

IL - Intermediate Language, is the compiled form of the .NET language source code. When .NET source code is compiled by the language specific compiler (say we compile C# code using csc.exe), it is compiled to a .NET binary, which is platform independent, and is called Intermediate Language code. The .NET binary also comprises of metadata.

Its important to note here that metadata describes the IL, whereas manifest describes the assembly.

VES - Virtual Execution System. The Virtual Execution System(VES) provides an environment for executing managed code. It provides direct support for a set of built-in data types, defines a hypothetical machine with an associated machine model and state, a set of control flow constructs, and an exception handling model.To a large extent, the purpose of the VES is to provide the support required to execute the Common Intermediate Language instruction set.

What is a class attribute in .NET?
Class Attributes - Is a kind of property attached with a class. It allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection. An example of a metadata attribute is [serializable], which can be attached to a class and means that instances of the class can be serialized.

[Serializable]
Public Class SampleClass
( ... )
1.1 What is .NET?
.NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc. See also Microsoft's definition.
1.2 When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.
1.3 What versions of .NET are there?
The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.
.NET 1.1 was released in April 2003 - it's mostly bug fixes for 1.0.
.NET 2.0 is expected in 2005.
1.4 What operating systems does the .NET Framework run on?
The runtime supports Windows Server 2003, Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on XP and Windows 2000/2003. Windows 98/ME cannot be used for development.
IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP Home.
The .NET Compact Framework is a version of the .NET Framework for mobile devices, running Windows CE or Windows Mobile.
The Mono project has a version of the .NET Framework that runs on Linux.
1.5 What tools can I use to develop .NET applications?
There are a number of tools, described here in ascending order of cost:
The .NET Framework SDK is free and includes command-line compilers for C++, C#, and VB.NET and various other utilities to aid development.
ASP.NET Web Matrix is a free ASP.NET development environment from Microsoft. As well as a GUI development environment, the download includes a simple web server that can be used instead of IIS to host ASP.NET apps. This opens up ASP.NET development to users of Windows XP Home Edition, which cannot run IIS.
Microsoft Visual C# .NET Standard 2003 is a cheap (around $100) version of Visual Studio limited to one language and also with limited wizard support. For example, there's no wizard support for class libraries or custom UI controls. Useful for beginners to learn with, or for savvy developers who can work around the deficiencies in the supplied wizards. As well as C#, there are VB.NET and C++ versions.
Microsoft Visual Studio.NET Professional 2003. If you have a license for Visual Studio 6.0, you can get the upgrade. You can also upgrade from VS.NET 2002 for a token $30. Visual Studio.NET includes support for all the MS languages (C#, C++, VB.NET) and has extensive wizard support.
At the top end of the price spectrum are the Visual Studio.NET 2003 Enterprise and Enterprise Architect editions. These offer extra features such as Visual Sourcesafe (version control), and performance and analysis tools. Check out the Visual Studio.NET Feature Comparison at http://msdn.microsoft.com/vstudio/howtobuy/choosing.asp
1.6 Why did they call it .NET?
I don't know what they were thinking. They certainly weren't thinking of people using search tools. It's meaningless marketing nonsense - best not to think about it.
2. Terminology
2.1 What is the CLI? Is it the same as the CLR?
The CLI (Common Language Infrastructure) is the definiton of the fundamentals of the .NET framework - the Common Type System (CTS), metadata, the Virtual Execution Environment (VES) and its use of intermediate language (IL), and the support of multiple programming languages via the Common Language Specification (CLS). The CLI is documented through ECMA - see http://msdn.microsoft.com/net/ecma/ for more details.
The CLR (Common Language Runtime) is Microsoft's primary implementation of the CLI. Microsoft also have a shared source implementation known as ROTOR, for educational purposes, as well as the .NET Compact Framework for mobile devices. Non-Microsoft CLI implementations include Mono and DotGNU Portable.NET.
2.2 What is the CTS, and how does it relate to the CLS?
CTS = Common Type System. This is the full range of types that the .NET runtime understands. Not all .NET languages support all the types in the CTS.
CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language. This interop is very fine-grained - for example a VB.NET class can inherit from a C# class.
2.3 What is IL?
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL during development. The IL is then converted to machine code at the point where the software is installed, or (more commonly) at run-time by a Just-In-Time (JIT) compiler.
2.4 What is C#?
C# is a new language designed by Microsoft to work with the .NET framework. In their "Introduction to C#" whitepaper, Microsoft describe C# as follows:
"C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced “C sharp”) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++."
Substitute 'Java' for 'C#' in the quote above, and you'll see that the statement still works pretty well :-).
If you are a C++ programmer, you might like to check out my C# FAQ.
2.5 What does 'managed' mean in the .NET context?
The term 'managed' is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.
Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code.
Managed data: This is data that is allocated and freed by the .NET runtime's garbage collector.
Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.

2.6 What is reflection?

All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember), or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).

3. Assemblies

3.1 What is an assembly?

An assembly is sometimes described as a logical .EXE or .DLL, and can be an application (with a main entry point) or a library. An assembly consists of one or more files (dlls, exes, html files etc), and represents a group of resources, type definitions, and implementations of those types. An assembly may also contain references to other assemblies. These resources, types and references are described in a block of data called a manifest. The manifest is part of the assembly, thus making the assembly self-describing.
An important aspect of assemblies is that they are part of the identity of a type. The identity of a type is the assembly that houses it combined with the type name. This means, for example, that if assembly A exports a type called T, and assembly B exports a type called T, the .NET runtime sees these as two completely different types. Furthermore, don't get confused between assemblies and namespaces - namespaces are merely a hierarchical way of organising type names. To the runtime, type names are type names, regardless of whether namespaces are used to organise the names. It's the assembly plus the typename (regardless of whether the type name belongs to a namespace) that uniquely indentifies a type to the runtime.
Assemblies are also important in .NET with respect to security - many of the security restrictions are enforced at the assembly boundary.
Finally, assemblies are the unit of versioning in .NET - more on this below.

3.2 How can I produce an assembly?
The simplest way to produce an assembly is directly from a .NET compiler. For example, the following C# program:
public class CTest
{
public CTest() { System.Console.WriteLine( "Hello from CTest" ); }
}
can be compiled into a library assembly (dll) like this:
csc /t:library ctest.cs
You can then view the contents of the assembly by running the "IL Disassembler" tool that comes with the .NET SDK.
Alternatively you can compile your source into modules, and then combine the modules into an assembly using the assembly linker (al.exe). For the C# compiler, the /target:module switch is used to generate a module instead of an assembly.

3.3 What is the difference between a private assembly and a shared assembly?

Location and visibility: A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the .NET framework classes.
Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies
Read this doc on Scribd: sql interview questions

Dotnet interview questions

Interview questions



Q1. Explain the differences between Server-side and Client-side code?

Ans. Server side code will execute at server (where the website is hosted) end, & all the business logic will execute at server end where as client side code will execute at client side (usually written in javascript, vbscript, jscript) at browser end.

Q2. What type of code (server or client) is found in a Code-Behind class?
Ans. Server side code.

Q3. How to make sure that value is entered in an asp:Textbox control?
Ans. Use a RequiredFieldValidator control.

Q4. Which property of a validation control is used to associate it with a server control on that page?

Ans. ControlToValidate property.


Q5. How would you implement inheritance using VB.NET & C#?

Ans. C# Derived Class : Baseclass
VB.NEt : Derived Class Inherits Baseclass


Q6. Which method is invoked on the DataAdapter control to load the generated dataset with data?

Ans. Fill() method.


Q7. What method is used to explicitly kill a user's session?

Ans. Session.Abandon()

Q8. What property within the asp:gridview control is changed to bind columns manually?
Ans. Autogenerated columns is set to false


Q9. Which method is used to redirect the user to another page without performing a round trip to the client?

Ans. Server.Transfer method.

Q10. How do we use different versions of private assemblies in same application without re-build?
Ans.Inside the Assemblyinfo.cs or Assemblyinfo.vb file, we need to specify assembly version.
assembly: AssemblyVersion

Q11. Is it possible to debug java-script in .NET IDE? If yes, how?
Ans. Yes, simply write "debugger" statement at the point where the breakpoint needs to be set within the javascript code and also enable javascript debugging in the browser property settings.

Q12. How many ways can we maintain the state of a page?
Ans. 1. Client Side - Query string, hidden variables, viewstate, cookies
2. Server side - application , cache, context, session, database

Q13. What is the use of a multicast delegate?
Ans. A multicast delegate may be used to call more than one method.

Q14. What is the use of a private constructor?
Ans. A private constructor may be used to prevent the creation of an instance for a class.


Q15. What is the use of Singleton pattern?

Ans. A Singleton pattern .is used to make sure that only one instance of a class exists.

Q16. When do we use a DOM parser and when do we use a SAX parser?
Ans. The DOM Approach is useful for small documents in which the program needs to process a large portion of the document whereas the SAX approach is useful for large documents in which the program only needs to process a small portion of the document.

Q17. Will the finally block be executed if an exception has not occurred?
Ans.Yes it will execute.


Q18. What is a Dataset?

Ans. A dataset is an in memory database kindof object that can hold database information in a disconnected environment.

Q19. Is XML a case-sensitive markup language?
Ans. Yes.

Q20. What is an .ashx file?
Ans. It is a web handler file that produces output to be consumed by an xml consumer client (rather than a browser).
Short Answer .NET Interview Questions (PAGE 2)
Q21. What is encapsulation?
Ans. Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality.

Q22. What is Overloading?
Ans. When we add a new method with the same name in a same/derived class but with different number/types of parameters, the concept is called overluoad and this ultimately implements Polymorphism.

Q23. What is Overriding?
Ans. When we need to provide different implementation in a child class than the one provided by base class, we define the same method with same signatures in the child class and this is called overriding.

Q24. What is a Delegate?
Ans. A delegate is a strongly typed function pointer object that encapsulates a reference to a method, and so the function that needs to be invoked may be called at runtime.

Q25. Is String a Reference Type or Value Type in .NET?
Ans. String is a Reference Type object.

Q26. What is a Satellite Assembly?
Ans. Satellite assemblies contain resource files corresponding to a locale (Culture + Language) and these assemblies are used in deploying an application globally for different languages.

Q27. What are the different types of assemblies and what is their use?
Ans. Private, Public(also called shared) and Satellite Assemblies.

Q28. Are MSIL and CIL the same thing?
Ans. Yes, CIL is the new name for MSIL.

Q29. What is the base class of all web forms?
Ans. System.Web.UI.Page

Q30. How to add a client side event to a server control?
Ans. Example... BtnSubmit.Attributes.Add("onclick","javascript:fnSomeFunctionInJavascript()");

Q31. How to register a client side script from code-behind?
Ans. Use the Page.RegisterClientScriptBlock method in the server side code to register the script that may be built using a StringBuilder.

Q32. Can a single .NET DLL contain multiple classes?
Ans. Yes, a single .NET DLL may contain any number of classes within it.

Q33. What is DLL Hell?
Ans. DLL Hell is the name given to the problem of old unmanaged DLL's due to which there was a possibility of version conflict among the DLLs.

Q34. can we put a break statement in a finally block?
Ans. The finally block cannot have the break, continue, return and goto statements.

Q35. What is a CompositeControl in .NET?
Ans. CompositeControl is an abstract class in .NET that is inherited by those web controls that contain child controls within them.

Q36. Which control in asp.net is used to display data from an xml file and then displayed using XSLT?
Ans. Use the asp:Xml control and set its DocumentSource property for associating an xml file, and set its TransformSource property to set the xml control's xsl file for the XSLT transformation.

Q37. Can we run ASP.NET 1.1 application and ASP.NET 2.0 application on the same computer?
Ans. Yes, though changes in the IIS in the properties for the site have to be made during deployment of each.

Q38. What are the new features in .NET 2.0?
Ans. Plenty of new controls, Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes.

Q39. Can we pop a MessageBox in a web application?
Ans. Yes, though this is done clientside using an alert, prompt or confirm or by opening a new web page that looks like a messagebox.

Q40. What is managed data?
Ans. The data for which the memory management is taken care by .Net runtime’s garbage collector, and this includes tasks for allocation de-allocation.
Short Answer .NET Interview Questions (PAGE 3)
Q41. How to instruct the garbage collector to collect unreferenced data?
Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method.

Q42. How can we set the Focus on a control in ASP.NET?
Ans. txtBox123.Focus(); OR Page.SetFocus(NameOfControl);

Q43. What are Partial Classes in Asp.Net 2.0?
Ans. In .NET 2.0, a class definition may be split into multiple physical files but partial classes do not make any difference to the compiler as during compile time, the compiler groups all the partial classes and treats them as a single class.

Q44. How to set the default button on a Web Form?
Ans.

Q45.Can we force the garbage collector to run?
Ans. Yes, using the System.GC.Collect(), the garbage collector is forced to run in case required to do so.

Q46. What is Boxing and Unboxing?
Ans. Boxing is the process where any value type can be implicitly converted to a reference type object while Unboxing is the opposite of boxing process where the reference type is converted to a value type.

Q47. What is Code Access security? What is CAS in .NET?
Ans. CAS is the feature of the .NET security model that determines whether an application or a piece of code is permitted to run and decide the resources it can use while running.

Q48. What is Multi-tasking?
Ans. It is a feature of operating systems through which multiple programs may run on the operating system at the same time, just like a scenario where a Notepad, a Calculator and the Control Panel are open at the same time.

Q49. What is Multi-threading?
Ans. When an application performs different tasks at the same time, the application is said to exhibit multithreading as several threads of a process are running.2

Q50. What is a Thread?
Ans. A thread is an activity started by a process and its the basic unit to which an operating system allocates processor resources.

Q51. What does AddressOf in VB.NET operator do?
Ans. The AddressOf operator is used in VB.NET to create a delegate object to a method in order to point to it.

Q52. How to refer to the current thread of a method in .NET?
Ans. In order to refer to the current thread in .NET, the Thread.CurrentThread method can be used. It is a public static property.

Q53. How to pause the execution of a thread in .NET?
Ans. The thread execution can be paused by invoking the Thread.Sleep(IntegerValue) method where IntegerValue is an integer that determines the milliseconds time frame for which the thread in context has to sleep.

Q54. How can we force a thread to sleep for an infinite period?
Ans. Call the Thread.Interupt() method.

Q55. What is Suspend and Resume in .NET Threading?
Ans. Just like a song may be paused and played using a music player, a thread may be paused using Thread.Suspend method and may be started again using the Thread.Resume method. Note that sleep method immediately forces the thread to sleep whereas the suspend method waits for the thread to be in a persistable position before pausing its activity.

Q56. How can we prevent a deadlock in .Net threading?
Ans. Using methods like Monitoring, Interlocked classes, Wait handles, Event raising from between threads, using the ThreadState property.

Q57. What is Ajax?
Ans. Asyncronous Javascript and XML - Ajax is a combination of client side technologies that sets up asynchronous communication between the user interface and the web server so that partial page rendering occur instead of complete page postbacks.

Q58. What is XmlHttpRequest in Ajax?
Ans. It is an object in Javascript that allows the browser to communicate to a web server asynchronously without making a postback.

Q59. What are the different modes of storing an ASP.NET session?
Ans. InProc (the session state is stored in the memory space of the Aspnet_wp.exe process but the session information is lost when IIS reboots), StateServer (the Session state is serialized and stored in a separate process call Viewstate is an object in .NET that automatically persists control setting values across the multiple requests for the same page and it is internally maintained as a hidden field on the web page though its hashed for security reasons.

Q60. What is a delegate in .NET?
Ans. A delegate in .NET is a class that can have a reference to a method, and this class has a signature that can refer only those methods that have a signature which complies with the class.
Short Answer .NET Interview Questions (PAGE 4)
Q61. Is a delegate a type-safe functions pointer?
Ans. Yes

Q62. What is the return type of an event in .NET?
Ans. There is No return type of an event in .NET.

Q63. Is it possible to specify an access specifier to an event in .NET?
Ans. Yes, though they are public by default.

Q64. Is it possible to create a shared event in .NET?
Ans. Yes, but shared events may only be raised by shared methods.

Q65. How to prevent overriding of a class in .NET?
Ans. Use the keyword NotOverridable in VB.NET and sealed in C#.

Q66. How to prevent inheritance of a class in .NET?
Ans. Use the keyword NotInheritable in VB.NET and sealed in C#.

Q67. What is the purpose of the MustInherit keyword in VB.NET?
Ans. MustInherit keyword in VB.NET is used to create an abstract class.

Q68. What is the access modifier of a member function of in an Interface created in .NET?
Ans. It is always public, we cant use any other modifier other than the public modifier for the member functions of an Interface.

Q69. What does the virtual keyword in C# mean?
Ans. The virtual keyword signifies that the method and property may be overridden.

Q70. How to create a new unique ID for a control?
Ans. ControlName.ID = "ControlName" + Guid.NewGuid().ToString(); //Make use of the Guid class

Q71A. What is a HashTable in .NET?
Ans. A Hashtable is an object that implements the IDictionary interface, and can be used to store key value pairs. The key may be used as the index to access the values for that index.

Q71B. What is an ArrayList in .NET?
Ans. Arraylist object is used to store a list of values in the form of a list, such that the size of the arraylist can be increased and decreased dynamically, and moreover, it may hold items of different types. Items in an arraylist may be accessed using an index.

Q72. What is the value of the first item in an Enum? 0 or 1?
Ans. 0

Q73. Can we achieve operator overloading in VB.NET?
Ans. Yes, it is supported in the .NET 2.0 version, the "operator" keyword is used.

Q74. What is the use of Finalize method in .NET?
Ans. .NET Garbage collector performs all the clean up activity of the managed objects, and so the finalize method is usually used to free up the unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc.

Q75. How do you save all the data in a dataset in .NET?
Ans. Use the AcceptChanges method which commits all the changes made to the dataset since last time Acceptchanges was performed.

Q76. Is there a way to suppress the finalize process inside the garbage collector forcibly in .NET?
Ans. Use the GC.SuppressFinalize() method.

Q77. What is the use of the dispose() method in .NET?
Ans. The Dispose method in .NET belongs to IDisposable interface and it is best used to release unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc from the memory. Its performance is better than the finalize() method.

Q78. Is it possible to have have different access modifiers on the get and set methods of a property in .NET?
Ans. No we can not have different modifiers of a common property, which means that if the access modifier of a property's get method is protected, and it must be protected for the set method as well.

Q79. In .NET, is it possible for two catch blocks to be executed in one go?
Ans. This is NOT possible because once the correct catch block is executed then the code flow goes to the finally block.

Q80. Is there any difference between System.String and System.StringBuilder classes?
Ans. System.String is immutable by nature whereas System.StringBuilder can have a mutable string in which plenty of processes may be performed.
Short Answer .NET Interview Questions (PAGE 5)
Q81. What technique is used to figure out that the page request is a postback?
Ans. The IsPostBack property of the page object may be used to check whether the page request is a postback or not. IsPostBack property is of the type Boolean.

Q82. Which event of the ASP.NET page life cycle completely loads all the controls on the web page?
Ans. The Page_load event of the ASP.NET page life cycle assures that all controls are completely loaded. Even though the controls are also accessible in Page_Init event but here, the viewstate is incomplete.

Q83. How is ViewState information persisted across postbacks in an ASP.NET webpage?
Ans. Using HTML Hidden Fields, ASP.NET creates a hidden field with an ID="__VIEWSTATE" and the value of the page's viewstate is encoded (hashed) for security.

Q84. What is the ValidationSummary control in ASP.NET used for?
Ans. The ValidationSummary control in ASP.NET displays summary of all the current validation errors.

Q85. What is AutoPostBack feature in ASP.NET?
Ans. In case it is required for a server side control to postback when any of its event is triggered, then the AutoPostBack property of this control is set to true.

Q86. What is the difference between Web.config and Machine.Config in .NET?
Ans. Web.config file is used to make the settings to a web application, whereas Machine.config file is used to make settings to all ASP.NET applications on a server(the server machine).

Q87. What is the difference between a session object and an application object?
Ans. A session object can persist information between HTTP requests for a particular user, whereas an application object can be used globally for all the users.

Q88. Which control has a faster performance, Repeater or Datalist?
Ans. Repeater.

Q89. Which control has a faster performance, Datagrid or Datalist?
Ans. Datalist.

Q90. How to we add customized columns in a Gridview in ASP.NET?
Ans. Make use of the TemplateField column.

Q91. Is it possible to stop the clientside validation of an entire page?
Ans. Set Page.Validate = false;

Q92. Is it possible to disable client side script in validators?
Ans. Yes. simply EnableClientScript = false.

Q93. How do we enable tracing in .NET applications?
Ans. <%@ Page Trace="true" %>

Q94. How to kill a user session in ASP.NET?
Ans. Use the Session.abandon() method.

Q95. Is it possible to perform forms authentication with cookies disabled on a browser?
Ans. No, it is not possible.

Q96. What are the steps to use a checkbox in a gridview?
Ans.
OnCheckedChanged="Check_Clicked">


Q97. What are design patterns in .NET?
Ans. A Design pattern is a repeatitive solution to a repeatitive problem in the design of a software architecture.

Q98. What is difference between dataset and datareader in ADO.NET?
Ans. A DataReader provides a forward-only and read-only access to data, while the DataSet object can carry more than one table and at the same time hold the relationships between the tables. Also note that a DataReader is used in a connected architecture whereas a Dataset is used in a disconnected architecture.

Q99. Can connection strings be stored in web.config?
Ans. Yes, in fact this is the best place to store the connection string information.

Q100. Whats the difference between web.config and app.config?
Ans. Web.config is used for web based asp.net applications whereas app.config is used for windows based applications.
I collected all these question from dotnetuncle.com u can check this site for more que.
For your Convinience I am displaying the document here click the last Button on the document to get enlarged.. Happy Reading :)
Read this doc on Scribd: DotNet SQL Interview Questions 007

Dotnet framework 3.0

Dotnet framework 3.0


Microsoft Corporate Vice President S. Somasegar announced that WinFX would be renamed the .NET Framework 3.0.

The .NET Framework 3.0 is Microsoft’s managed code programming model. It is a superset of the .NET Framework 2.0, combining .NET Framework 2.0 components with new technologies for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.To support this variety, the .NET Framework includes a broad set of supporting class libraries, including: Windows Presentation Foundation (WPF), for visually stunning user experiences on Windows clients; Windows Communication Foundation (WCF), enabling fast and flexible communications among applications across your enterprise; Windows Workflow Foundation (WF), allowing developers to build workflows into any application; ASP.NET, for high-performance and interactive Web-based applications; Libraries for handling XML, data, IO, cryptography, text-to-speech, and more.

There are no changes to the version of the .NET Framework 2.0 components included in the .NET Framework 3.0. This means that the millions of developers who use .NET today can use the skills they already have to start building .NET Framework 3.0 applications. It also means that applications that run on the .NET Framework 2.0 today will continue to run on the .NET Framework 3.0.

Here’s a look at the structure of the .NET Framework 3.0:

.NET Framework 3.0

Windows Communication Foundation

Windows Communication Foundation (formerly code-named “Indigo”) is a set of .NET technologies for building and running connected systems. It is a new breed of communications infrastructure built around the Web services architecture. Advanced Web services support in Windows Communication Foundation provides secure, reliable, and transacted messaging along with interoperability. The service-oriented programming model of Windows Communication Foundation is built on the Microsoft .NET Framework and simplifies development of connected systems. Windows Communication Foundation unifies a broad array of distributed systems capabilities in a composable and extensible architecture, spanning transports, security systems, messaging patterns, encodings, network topologies, and hosting models. Windows Communication Foundation will be available for Windows Vista™ as well as for Windows XP and Windows Server 2003.

Windows Presentation Foundation

The Microsoft Windows Presentation Foundation provides the foundation for building applications and high fidelity experiences in Windows Vista, blending together application UI, documents, and media content, while exploiting the full power of your computer. The functionality extends to the support for Tablet and other forms of input, a more modern imaging and printing pipeline, accessibility and UI automation infrastructure, data driven UI and visualization, as well as the integration points for weaving the application experience into the Windows shell.

Windows Workflow Foundation

Windows Workflow Foundation is the programming model, engine and tools for quickly building workflow enabled applications on Windows. It consists of a .NET Framework version 3.0 (formerly WinFX) namespace, an in-process workflow engine, and designers for Visual Studio 2005. Windows Workflow Foundation is available for both client and server versions of Windows. Windows Workflow Foundation includes support for both system workflow and human workflow across a wide range of scenarios including: workflow within line of business applications, user interface page-flow, document-centric workflow, human workflow, composite workflow for service oriented applications, business rule driven workflow and workflow for systems management.

Windows CardSpace

Windows CardSpace (formerly “InfoCard”) is a Microsoft .NET Framework version 3.0 (formerly WinFX) component that provides the consistent user experience required by the identity metasystem. It is specifically hardened against tampering and spoofing to protect the end user’s digital identities and maintain end-user control.

Saturday, February 23, 2008

Application development with Microsoft .NET application blocks

Application blocks

Takeaway: The Microsoft Patterns & Practices group offers chunks of reusable code for developers who are working with .NET languages. Here's a look at the eight application blocks and how you can use them in your next application.

By Mike Gunderloy

Most consultants understand instinctively that time is money: The less time it takes you to deliver a tested, working, complete solution, the higher your hourly rate. One of the keys to better productivity is code reuse. If you have previously tested code that fits the current project’s requirements, you can drop it in to the new application and go on to the next task.

But there’s no reason to limit code reuse to code that you’ve written yourself. There is a tremendous amount of code available on the Internet that you can use. Beware of quality control, of course; downloaded code varies widely in quality. If you’re working in one of the core .NET languages, though, there’s a high-quality repository of reusable code available: the Microsoft Patterns and Practices group. Here’s a look at some of the goodies that this group can provide for your .NET projects.

Patterns and practices
During the last decade, Microsoft realized that it wasn’t enough to just ship development products and then let the rest of us figure out what to do with them. Today’s development environments and client requirements are so complex that it can take years to learn how to write excellent applications. And today’s help files, though comprehensive, can be overwhelming. (Just reading about all of the classes and members in the .NET Framework Class Library [FCL] can take months.)

That’s where the Patterns & Practices group comes into play. Available through the Microsoft Patterns & Practices Web site, the patterns and practices are a series of tested and proven recommendations from Microsoft for use in real-world development. You’ll find four types of information on the site:

1. Patterns that address specific architecture, design, and implementation problems (You can think of these as structured solutions that show you how to do things.)
2. Reference architectures that help you plan server deployments, networks, and other parts of your infrastructure
3. Lifecycle practices that address such issues as trouble-free deployment and operational monitoring
4. Reference building blocks and services that provide you with reusable code that you can drop into your own solution


Of particular interest to the .NET developer are the series of application blocks that you’ll find in the last of these categories.

Application blocks
The application blocks are chunks of reusable code (and documentation) to meet common requirements. Eight application blocks are available:

* The Aggregation application block for aggregating and transforming information from multiple sources
* The Asynchronous Invocation application block for agent-based asynchronous processing
* The Caching application block for caching information in distributed applications (Note that for pure ASP.NET applications, you should probably use the ASP.NET cache instead.)
* The Configuration Management application block for securely reading and writing configuration information from a variety of sources
* The Data Access application block to simplify ADO.NET data access
* The Exception Management application block, which provides an extensible framework for handling exceptions
* The Updater application block, which provides a "pull model" for updating desktop applications over a network
* The User Interface Process application block, a model for writing UI and workflow processes as a distinct layer


What’s in an Application Block?
To get a sense of what the application blocks can do for you, I’ll dig into one of them a bit deeper. Downloading the Aggregation application block gives you a single Windows Installer (MSI) file. Run this file to install the application block on your development computer. Here’s what you’ll get:

* Source code (in both C# and VB.NET) for the Aggregation application block itself
* QuickStart samples (in both C# and VB.NET)
* Documentation in the form of an HTML Help file


The first thing to note is that the application block is supplied as source code rather than as a compiled library. This serves two purposes. First, you can browse through the code and use it for learning, whether you’re more comfortable in C# or in VB.NET. The code in the application blocks tends to be well-structured and well-commented; it seems that there is an internal review process at Microsoft that precedes release.

Second, with shipping source (in Visual Studio .NET 2002 projects), Microsoft offers you the most flexibility in using the code. You can upgrade it to VS.NET 2003, incorporate pieces directly into your own solutions, sign the code so you can deploy it to the GAC, or just compile it as-is and use it as a private library.

The rest of the package ensures that you’re not limited to the source code for the application block when you want to learn what it does. For starters, there’s the QuickStart sample code, which is designed to show the application block in a realistic setting.

For example, the sample for the Aggregation application block shows how to use it in conjunction with the Exception Management application block, the Asynchronous application block, and the Caching application block.
Application development with Microsoft .NET application blocks

Wednesday, February 20, 2008

ASP.NET Cookies Overview

A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site.
A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site.

For example, if a user requests a page from your site and your application sends not just a page, but also a cookie containing the date and time, when the user's browser gets the page, the browser also gets the cookie, which it stores in a folder on the user's hard disk.

Later, if user requests a page from your site again, when the user enters the URL the browser looks on the local hard disk for a cookie associated with the URL. If the cookie exists, the browser sends the cookie to your site along with the page request. Your application can then determine the date and time that the user last visited the site. You might use the information to display a message to the user or check an expiration date.

Cookies are associated with a Web site, not with a specific page, so the browser and server will exchange cookie information no matter what page the user requests from your site. As the user visits different sites, each site might send a cookie to the user's browser as well; the browser stores all the cookies separately.

Cookies help Web sites store information about visitors. More generally, cookies are one way of maintaining continuity in a Web application—that is, of performing state management. Except for the brief time when they are actually exchanging information, the browser and Web server are disconnected. Each request a user makes to a Web server is treated independently of any other request. Many times, however, it's useful for the Web server to recognize users when they request a page. For example, the Web server on a shopping site keeps track of individual shoppers so the site can manage shopping carts and other user-specific information. A cookie therefore acts as a kind of calling card, presenting pertinent identification that helps an application know how to proceed.

Cookies are used for many purposes, all relating to helping the Web site remember users. For example, a site conducting a poll might use a cookie simply as a Boolean value to indicate whether a user's browser has already participated in voting so that the user cannot vote twice. A site that asks a user to log on might use a cookie to record that the user already logged on so that the user does not have to keep entering credentials.
Cookie Limitations

Most browsers support cookies of up to 4096 bytes. Because of this small limit, cookies are best used to store small amounts of data, or better yet, an identifier such as a user ID. The user ID can then be used to identify the user and read user information from a database or other data store. (See the section "Cookies and Security" below for information about security implications of storing user information.)

Browsers also impose limitations on how many cookies your site can store on the user's computer. Most browsers allow only 20 cookies per site; if you try to store more, the oldest cookies are discarded. Some browsers also put an absolute limit, usually 300, on the number of cookies they will accept from all sites combined.

A cookie limitation that you might encounter is that users can set their browser to refuse cookies. If you define a P3P privacy policy and place it in the root of your Web site, more browsers will accept cookies from your site. However, you might have to avoid cookies altogether and use a different mechanism to store user-specific information. A common method for storing user information is session state, but session state depends on cookies, as explained later in the section "Cookies and Session State."
Although cookies can be very useful in your application, the application should not depend on being able to store cookies. Do not use cookies to support critical features. If your application must rely on cookies, you can test to see whether the browser will accept cookies. See the "Checking Whether a Browser Accepts Cookies" section later in this topic.
Writing Cookies

The browser is responsible for managing cookies on a user system. Cookies are sent to the browser via the HttpResponse object that exposes a collection called Cookies. You can access the HttpResponse object as the Response property of your Page class. Any cookies that you want to send to the browser must be added to this collection. When creating a cookie, you specify a Name and Value. Each cookie must have a unique name so that it can be identified later when reading it from the browser. Because cookies are stored by name, naming two cookies the same will cause one to be overwritten.

You can also set a cookie's date and time expiration. Expired cookies are deleted by the browser when a user visits the site that wrote the cookies. The expiration of a cookie should be set for as long as your application considers the cookie value to be valid. For a cookie to effectively never expire, you can set the expiration date to be 50 years from now.
If you do not set the cookie's expiration, the cookie is created but it is not stored on the user's hard disk. Instead, the cookie is maintained as part of the user's session information. When the user closes the browser, the cookie is discarded. A non-persistent cookie like this is useful for information that needs to be stored for only a short time or that for security reasons should not be written to disk on the client computer. For example, non-persistent cookies are useful if the user is working on a public computer, where you do not want to write the cookie to disk.

You can add cookies to the Cookies collection in a number of ways. The following example shows two methods to write cookies:
Response.Cookies["userName"].Value = "patrick";
Response.Cookies["userName"].Expires = DateTime.Now.AddDays(1);

HttpCookie aCookie = new HttpCookie("lastVisit");
aCookie.Value = DateTime.Now.ToString();
aCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(aCookie);
The example adds two cookies to the Cookies collection, one named userName and the other named lastVisit. For the first cookie, the values of the Cookies collection are set directly. You can add values to the collection this way because Cookies derives from a specialized collection of type NameObjectCollectionBase.

For the second cookie, the code creates an instance of an object of type HttpCookie, sets its properties, and then adds it to the Cookies collection via the Add method. When you instantiate an HttpCookie object, you must pass the cookie name as part of the constructor.

Both examples accomplish the same task, writing a cookie to the browser. In both methods, the expiration value must be of type DateTime. However, the lastVisited value is also a date-time value. Because all cookie values are stored as strings, the date-time value has to be converted to a String .
Cookies with More Than One Value

You can store one value in a cookie, such as user name and last visit. You can also store multiple name-value pairs in a single cookie. The name-value pairs are referred to as subkeys. (Subkeys are laid out much like a query string in a URL.) For example, instead of creating two separate cookies named userName and lastVisit, you can create a single cookie named userInfo that has the subkeys userName and lastVisit.

You might use subkeys for several reasons. First, it is convenient to put related or similar information into a single cookie. In addition, because all the information is in a single cookie, cookie attributes such as expiration apply to all the information. (Conversely, if you want to assign different expiration dates to different types of information, you should store the information in separate cookies.)

A cookie with subkeys also helps you limit the size of cookie files. As noted earlier in the "Cookie Limitations" section, cookies are usually limited to 4096 bytes and you can't store more than 20 cookies per site. By using a single cookie with subkeys, you use fewer of those 20 cookies that your site is allotted. In addition, a single cookie takes up about 50 characters for overhead (expiration information, and so on), plus the length of the value that you store in it, all of which counts toward the 4096-byte limit. If you store five subkeys instead of five separate cookies, you save the overhead of the separate cookies and can save around 200 bytes.

To create a cookie with subkeys, you can use a variation of the syntax for writing a single cookie. The following example shows two ways to write the same cookie, each with two subkeys:
Response.Cookies["userInfo"]["userName"] = "patrick";
Response.Cookies["userInfo"]["lastVisit"] = DateTime.Now.ToString();
Response.Cookies["userInfo"].Expires = DateTime.Now.AddDays(1);

HttpCookie aCookie = new HttpCookie("userInfo");
aCookie.Values["userName"] = "patrick";
aCookie.Values["lastVisit"] = DateTime.Now.ToString();
aCookie.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(aCookie);
For more info Click below link




ASP.NET Cookies Overview