Wednesday, July 31, 2013

Web Services Interview Questions & Answers

1. What are Windows services?

Windows services, previously known as NT services, are applications that are installed on the system as system services. In other words, Windows services are applications that run in the background with the Windows operating system. The primary use of Windows services is to reduce the consumption of memory required for performing backend operations. Let's take an example to understand this easily. Suppose you want to perform a variety of functions, such as monitor the performance of your computer or application, check the status of an application, and manage various devices, such as printers.

In such a case, you can use Windows services to reduce memory consumption. In addition, Windows services can run on your system even if you have not logged on to your computer. In addition, these services do not have any user interface.

2. Can you share a process between Windows services?

Yes, you can share a process between Windows services.

3. In .NET, which is the parent class to create all Windows services?

The ServiceBase class is the parent class to create all Windows services.

4. Which class in .NET is used to install a Windows service?

The ServiceInstaller class, also known as the project installer class, is used to install a Windows service.

5. While installing a Windows service, an EventLogInstaller class is automatically created to install the event log related to the particular service. Is it true?

Yes, it is true.

6. Which property of the ServiceBase class can be used to specify whether a service can be paused and resumed?

The CanPauseAndContinue property provides such type of service.

7. Describe the services that UDDI provides to Web applications.

UDDI provides the following types of services to a Web application:
XML Schema for business descriptions - Includes information about the service publisher (contact name, address, and so on) and specifications on the Web service
Web registry of Web services - Includes business, service, and binding information for the Web service

8. Write the file extension for a Web service.

A Web service file extension is .asm file. For example, service1.asmx is a Web service file.

9. Which method is used to uninstall the Windows services?

The Uninstall() method is used to uninstall the Windows services.

10. What is the use of the mustUnderstand attribute in the Header element of a SOAP message?

The mustUnderstand attribute indicates that a header entry is either required or optional for the recipient to process further.

11. Explain the WSDL.

WSDL is a short form for Web Services Description Language, which is used to describe a Web service in terms of the messages that it creates and accepts. The WSDL document is an XML file that contains the interface schema for the Web service. It identifies the methods that are used during the exchange between a Web service consumer and a Web service provider. The following are the elements contained in the WSDL document:

Types - Describe the variations of data types that are used to exchange messages between the user and the provider.
Message - Describes the actual message or method call.
portType - Describes the set of operations and each related message.
binding - Describes the protocol details.
service - Used to make groups a set of related ports together.

12. What advantage UDDI has over DISCO?

The UDDI directory has an advantage over a DISCO file, as it provides a single location where a client can find the Web services offered by different organizations.

13. How can you ensure that only authorized users access your Web service?

You should use the <authorization> element to ensure that only authorized users access your Web service. This element allows or denies access to your Web service according to their role.

14. Describe the EventLog class.

The EventLog class is used to access the Windows event logs from Windows services. Using EventLog, you can also customize Windows event logs that record information about important software and hardware events, such as the events of the .NET controls, keyboard, or other hardware devices.

The EventLog class allows you to read or write to event logs, delete logs, and create as well as delete event sources. You can use the EventLog class to create event logs while creating an event source. An event source can be used to write to only one event log at a particular time. However, it is possible to associate one event log to multiple sources.

15. How can you prevent your Web services from unauthorized access?

The following are the ways to prevent your Web service from unauthorized access:
Using encryption and message-based security.
Using authentication and access controls for the Web service.

16. Explain the concept of Web services in brief.

A Web service may be defined as an independent and self-sustained unit of a software application that is hosted on the Web and implement specific functionalities to execute the business logic. A Web service provides so many functionalities, such as generating pay slips for employees, computing tax, broadcasting weather report, and providing updated news. The Web service allows application to share information or exchange data with other applications across different operating systems and hardware.

Therefore, the work of a Web service is to unite software by exchanging data irrespective of their operating systems, supported hardware, and programming language used in their development. The Web services transfer data in the XML format and use Simple Object Access Protocol (SOAP) to communicate. It is an XML based protocol. The Web services use Web Services Description Language (WSDL) and Universal Description, Discovery, and Integration (UDDI) to describe itself.

17. What advantages have Web services over Component Object Model (COM) and Distributed Component Object Model (DCOM)?

The advantages of Web services over COM and DCOM are as follows:
Web services are simple to use and can be implemented on varied platforms.
Web services are loosely coupled; as a result, their interfaces and methods can be extended.
Web services do not carry any state information with them so that multiple requests can be processed simultaneously.


18. Mention the namespace that you must import in code to build a Web service.

System.Web.Services is the elementary namespace, which must be imported to develop code of a Web service.

19. What does the portType element of a WSDL document contain?

The portType element contains the operations exposed by the Web service, and the messages involved in the communication between the Web service and its consumers.

20. What is DISCO?

DISCO is a technology developed by Microsoft to publish and discover Web services. It discovers URLs of all XML Web services located on a Web server and creates a list of these Web services in a file called as a DISCO file.

21. Which two methods are used to discover the URL of Web services?

The two methods to discover the URL of Web services are Web service discovery tool (Disco.exe) and UDDI.

22. Which step is necessary to perform before a Web service can be consumed?

It is necessary to build a proxy class by using the wsdl.exe utility before a Web service can be consumed.

23. Which property of the WebMethod attribute allows you to maintain the state of objects across sessions in a Web method?

The WebMethod attribute's EnableSession property enables you to enable session state for a Web method.

24. Write the names of public properties defined in the WebService class.

There are many properties defined in the WebServices class:
Application - Obtains the application object for the current HTTP request
Context - Obtains the HttpContext object for the current request, which encapsulates all HTTP-specific context used by the HTTP server to process Web requests
Server - Obtains the HttpServerUtility object for the current request
Session - Obtains the HttpSessionState object for the current request
SoapVersion - Obtains the version of the SOAP protocol used to make the SOAP request to a Web service
User - Obtains the Server User Object. This property can be used to authenticate whether a user is authorized to execute the request.

25. What do you understand by SOAP encoding?

The Serialization of the types, such as integers and strings, inside a SOAP message is called encoding. The SOAP objects use XML elements and attributes to serialized data, for example, encodingStyle is an attribute of the Envelop element, which is used to specify the encoding rules for a SOAP object.

26. What is the use of a .disco file?

A client application uses a .disco file to locate or discover the documents that contain the description of a Web service. The .disco file contains links to other resources, which describe essential features, such as capabilities of a Web service. The links contained in a .disco file can refer to other discovery documents or XSD schemas. The description about the services and capabilities of a Web service is written in Web services Description Language (WSDL). A .disco file can also contain the information about other XML Web services that reside on the same or a different Web server.

27. Mention the name of the directory where it is necessary to locate the proxy file to use a Web service.

The proxy file must be stored in the /bin directory. This directory is situated under the root directory of the application.

28. Does a Web service have state?

The Web services do not have any technique to maintain state. However, it can access ASP.NET objects, such as application and session if they extend from the WebService base class.

29. Which namespace must be included in a code that enables a XML Web service to write events in an event log file?

The System.Diagnostics is the namespace, which must be included in a code to enable a Web service for writing events in an event log file.

30. Which tool installs the DLL on your local computer and installs the Windows service in a transactional manner?

The Installutil.exe tool. 

Wednesday, July 24, 2013

Javascript Interview Questions & Answers

1- What is JavaScript? 
JavaScript is a scripting language most often used for client-side web development.

2- What is the difference between JavaScript and Jscript? 
Both JavaScript and Jscript are almost similar. JavaScript was developed by Netscape. Microsoft reverse engineered Javascript and called it JScript.

3- How do we add JavaScript onto a web page? 
Ans:There are several way for adding JavaScript on a web page, but there are two ways which are commonly used by developers
If your script code is very short and only for single page, then following ways are the best:
a) You can place <script type="text/javascript"> tag inside the <head> element.

Code

<head>
<title>Page Title</title>
<script language="JavaScript" type="text/javascript">
   var name = "Vikas Ahlawta"
   alert(name);
</script>
</head>
b) If your script code is very large, then you can make a JavaScript file and add its path in the following way:

Code

<head>
<title>Page Title</title>
<script type="text/javascript" src="myjavascript.js"></script>
</head>
4. Is JavaScript case sensitive? 
Yes!
A function getElementById is not the same as getElementbyID.

5- What are the types used in JavaScript? 
String, Number, Boolean, Function, Object, Null, Undefined.

6. What are the boolean operators supported by JavaScript? And Operator: &&
Or Operator: ||
Not Operator: !

7-What is the difference between “==” and “===”?
Ans:
“==” checks equality only,
“===” checks for equality as well as the type.

8. How to access the value of a textbox using JavaScript?

Code

<!DOCTYPE html>
<html>
<body>
Full name: <input type="text" id="txtFullName"
name="FirstName" value="Vikas Ahlawat">
</body>
</html>
There are following ways to access the value of the above textbox:


var name = document.getElementById('txtFullName').value;

alert(name);
or:

we can use the old way:


document.forms[0].mybutton.

var name = document.forms[0].FirstName.value;

alert(name);
Note: This uses the "name" attribute of the element to locate it.

9. What are the ways of making comments in JavaScript?
Ans:


// is used for line comments
ex:- var x=10; //comment text

/*
*/  is used for block comments
ex:-

var x= 10; /* this is
block comment example.*/
10. How will you get the Checkbox status whether it is checked or not?
Ans:


var status = document.getElementById('checkbox1').checked;
alert(status);
will return true or false.

11. How to create arrays in JavaScript?
There are two ways to create array in JavaScript like other languages:

a) The first way to create array
Declare Array:

Code

var names = new Array();
Add Elements in Array:-
names[0] = "Vikas";
names[1] = "Ashish";
names[2] = "Nikhil";
b) This is the second way:


var names = new Array("Vikas", "Ashish", "Nikhil");
12If an array with name as "names" contain three elements, then how will you print the third element of this array?
Ans: Print third array element document.write(names[2]);
Note:- Array index starts with 0.

13How do you submit a form using JavaScript?
Ans:Use document.forms[0].submit();

14What does isNaN function do?
Ans: It returns true if the argument is not a number.
Example:

Code

document.write(isNaN("Hello")+ "<br>");
document.write(isNaN("2013/06/23")+ "<br>");
document.write(isNaN(123)+ "<br>");
The output will be:


true
true
false
15. What is the use of Math Object in JavaScript?
Ans: The math object provides you properties and methods for mathematical constants and functions.
ex:-

Code

var x = Math.PI; // Returns PI
var y = Math.sqrt(16); // Returns the square root of 16
var z = Math.sin(90);    Returns the sine of 90

16What do you understand by this keyword in JavaScript?
Ans:"this" keyword refers to the current object like other language.

17What does "1"+2+4 evaluate to?
Ans: Since 1 is a string, everything is a string, so the result is 124.

18What does 3+4+"7" evaluate to?
Ans: Since 3 and 4 are integers, this is number arithmetic, since 7 is a string, it is concatenation, so 77 is the result.

19) How do you change the style/class on any element using JavaScript?
Ans:

Code

document.getElementById(“myText”).style.fontSize = “10";
-or-

document.getElementById(“myText”).className = “anyclass”;
20. Does JavaScript support foreach loop?
Ans: No.

21What looping structures are there in JavaScript?
Ans: for, while, do-while loops

22What is an object in JavaScript, give an example?
Ans: An object is just a container for a collection of named values:

// Create the man object

Code

var man = new Object();
man.name = 'Vikas Ahlawat';
man.living = true;
man.age = 27;
23. How you will add function as a property in a JavaScript object? Give an example.


Code

var man = new Object();
man.name = 'Vikas Ahlawat';
man.living = true;
man.age = 27;
man.getName = function() { return man.name;}
console.log(man.getName()); // Logs 'Vikas Ahlawat'.

24What is the similarity between the 1st and 2nd statement?
1st:- var myString = new String('male'); // An object.
2nd:- var myStringLiteral = 'male'; // Primitive string value, not an object.
Ans: Both will call String() constructor function
You can confirm it by running the following statement:


console.log(myString.constructor, myStringLiteral.constructor);
25. What will be the output of the following statements?

Code

var myString = 'Vikas' // Create a primitive string object.
var myStringCopy = myString; // Copy its value into a new variable.
var myString = null; // Manipulate the value
console.log(myString, myStringCopy);
Ans: // Logs 'null Vikas'
26Consider the following statements and tell what would be the output of the logs statements?


var price1 = 10;
var price2 = 10;
var price3 = new Number('10'); // A complex numeric object because new was used.
console.log(price1 === price2);
console.log(price1 === price3);
Ans:

console.log(price1 === price2); // Logs true.
console.log(price1 === price3); /* Logs false because price3
contains a complex number object and price 1
is a primitive value. */

27. What would be the output of the following statements?

var object1 = { same: 'same' };
var object2 = { same: 'same' };
console.log(object1 === object2);
Logs false, JavaScript does not care that they are identical and of the same object type.
When comparing complex objects, they are equal only when they reference the same object (i.e., have the same address). Two variables containing identical objects are not equal to each other since they do not actually point at the same object.

28- What would be the output of the following statements?

Code

var object1 = { same: 'same' };
var object2 = object1;
console.log(object1 === object2);
 Logs true

29. What is this? var myArray = [[[]]];
 Three dimensional array

30. Name any two JavaScript functions which are used to convert nonnumeric values into numbers? 

Number()
parseInt()
parseFloat()
Code

var n1 = Number(“Hello world!”); //NaN
var n2 = Number(“”);             //0
var n3 = Number(“000010”);       //10
var n4 = Number(true);           //1
var n5 = Number(NaN);            //NaN

31.What is relationship between JavaScript and ECMAScript? 

ECMAScript is yet another name for JavaScript (other names include LiveScript). The current JavaScript that you see supported in browsers is ECMAScript revision 3.

32.What does undefined value mean in javascript? 

Undefined value means the variable used in the code doesnt exist or is not assigned any value or the property doesnt exist.

33.How to hide javascript code from old browsers that dont run it? 

Use the below specified style of comments
<script language=javascript>

<!--
javascript code goes here

// -->

34.What does the "Access is Denied" IE error mean? 

The "Access Denied" error in any browser is due to the following reason.
A javascript in one window or frame is tries to access another window or frame whose
document's domain is different from the document containing the script.

35.What is the difference between undefined value and null value? 

(i)Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null
(ii)typeof undefined variable or property returns undefined whereas
typeof null value returns object

36.How to detect the operating system on the client machine? 

In order to detect the operating system on the client machine, the navigator.appVersion

string (property) should be used.

Wednesday, July 17, 2013

XSLT Interview Questuions & Answers

1. What os XSLT?
XSLT stands for XSL Transformations. XSLT is a language for transforming XML documents into XHTML documents or to other XML documents.XPath is a language for navigating in XML documents.

2.What is XSLT?

  • XSLT stands for XSL Transformations
  • XSLT is the most important part of XSL
  • XSLT transforms an XML document into another XML document
  • XSLT uses XPath to navigate in XML documents
  • XSLT is a W3C Recommendation.


3.How Does it Work?
In the transformation process, XSLT uses XPath to define parts of the source document that should match one or more predefined templates. When a match is found, XSLT will transform the matching part of the source document into the result document.

4.How you define template in XSLT?
An XSL style sheet consists of one or more set of rules that are called templates.

A template contains rules to apply when a specified node is matched.
The <xsl:template> element is used to build templates.

The match attribute is used to associate a template with an XML element. The match attribute can also be used to define a template for the entire XML document. The value of the match attribute is an XPath expression (i.e. match="/" defines the whole document).

5.How to use filtering in XSLT? 
We can filter the XNL output by using filter operators.Some Legal filter operators are given below:
1.=(equal to)
2.!=(not equal to)
3.<(less than)
4.>(greater than)
I have given you a example. In this I have uses '=' equal to filer operation.

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Book Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Author</th>

6.How to transform an XML into XHTML? 
Below, I write an example which show you how ransform an XML into XHTML.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html"/>
<xsl:template match="/persons">
<html>
<head>
<title>Test an XML Example</title>
</head>
<body>
<h1>Persons</h1>
<ul>
<xsl:apply-templates select="person">
<xsl:sort select="family-name" />
</xsl:apply-templates>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="person">
<li>
<xsl:value-of select="family-name"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="name"/>
</li>
</xsl:template>
</xsl:stylesheet>
To get output on the XHTML we write like that,

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Test an XML Example</title> </head>
<body>
<h1>Persons</h1>
<ul>
<li>gupta, Abhi</li>
<li>jain, sudi</li>
</ul>
</body>
</html>

7.How to use <xsl:sort>element in XSLT?
The <xsl:sort> element is used to sort the output.
To sort the output, simply add an <xsl:sort> element inside the <xsl:for-each> element in the XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Title</th>
      <th>Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
      <xsl:sort select="artist"/>
      <tr>
        <td><xsl:value-of select="title"/></td>
        <td><xsl:value-of select="artist"/></td>
      </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>

8.Can you use the XSLT to convert html into VXML? 
Yes

9.Do you feel that you have chosen the right technology XSLT? 
Yes

10.What is the function of XSLT?

  •  XSLT is the transformation language used for XML documents and it performs high level of functions.
  • XSLT provides a way to solve the complex problems like styling and the operations related to the generation of table and its contents. 
  • It also provides the support for the indexes and other processing languages that can be integrated with one another. 
  • The transformation language is used to provide XSL to generate the HTML pages using the XML data. 
  • It defines the semantics and syntax using the XSLT language and expresses the XML document in a well formed manner.

11.What are the specifications defined in XSLT?

  • -The specifications are defined using the syntax and semantics of XSLT language and uses the namespace fundamentals of XML.
  • XML names can include both the elements that are defined using the XSLT and those that are not defined. 
  •  XSLT defines the parameters and XML namespace that can be used to refer the syntax and semantics of XSLT namespace. 
  • The semantics that are used with XSLT namespace need to be defined in the correct order. 
  • It provides the syntax for all the specifications that needs to be written and allow the user to use the elements given.

12.What are the rules defined by the transformation of XSL?
 The transformation of XSL provides the XSLT that describes the rules to define the transformation of the source tree into result tree.

  • It also provides the pattern that is associated with the templates and also with the structure of it. 
  • It uses the templates that allow the creation of the result tree by using the modification made in source tree. 
  • The transformation is described in the rules for transforming the pattern templates according to the requirement. 
  • The pattern is made against the elements and it is matched using the source tree and with other elements.


13.What are the steps in the instantiation of a template?

  • The template can be instantiated using the source element of the tree and it can create some part of the result tree. 
  • The template can consist of elements using the XSLT namespace that provides the instructions for creating the fragments. 
  • After the template instantiation the instructions are executed using the tree fragments. 
  • The instructions are processed and it is descendant of the source elements that consists under the source tree.
  • Processing the elements in the source tree creates a result tree fragment on which template rule can be applied.

14.What is the stylesheet structure used with XSLT?

  • XSLT uses the namespaces that provide the recognition for the elements for the use in the stylesheet.
  • XSLT uses the elements that get recognized using the stylesheet not the source document that is used.
  • The list of XSLT defined elements are used in the category of B elements and it is not extended using the additional elements or attributes. 
  • The extensions that are used provide the separate namespace used for additional instruction elements.
  • The structure must have identification for the element mechanism that is specified in the elements.

15.How important is an element’s attributes used in XSLT?

  •  Elements are the core part of XSLT namespace as it uses an attribute with the elements. 
  • XSLT provide the expanded name to be given using the non-null namespace URI that can be used in the namespace. 
  • The attributes are present to change the behaviour of XSLT element and functions that gets defined in XML documents. 
  • XSLT processor is used to process the attributes and provide the recognition for the namespace URI.
  •  The attribute provide unique identifier or optimization hints in the documents so that they can be used.

16.What are the different elements contain in xsl:stylesheet?

  • xsl:stylesheet is an element container that consists of the following types of elements:
  • xsl:import: this is used to import the file from one place to another by using the command. 
  • xsl:include: this includes the libraries and the functions used in XSLT stylesheet language. 
  • xsl:strip-space: this is used to strip the additional space provided by the whitespaces, etc. 
  •  xsl:output: this represents the output of the input that is being provided to the XSLT. 
  •  xsl:key: this consists of the key that is used to open the protected files and documents. 
  •  xsl:template: this is used to provide the template that can be included using the command.

17.Write a program to show the element is occurring as a child?

  • The element can be used as a child when it is used in xsl:stylesheet element that is the top-level element.
  • The element structure is made in a hierarchical fashion so that it is easy to implement it. 
  • Ellipses (...) are used to indicate that attribute values or content for the use of creating files.
  • The program is written as follows:
  • <xsl:stylesheet version="1.0 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:import href="..."/>
<xsl:include href="..."/>
<xsl:strip-space elements="..."/>
<xsl:variable name="...">...</xsl:variable>
<xsl:param name="...">...</xsl:param>
<xsl:template match="...">...</xsl:template>
<xsl:template name="...">...</xsl:template>
</xsl:stylesheet>

18.What happens about the presence of the top-level element?

  •  The top-level elements don’t have any effect on the behaviour of XSLT elements. 
  •  The functions that are defined with it also don’t have any affect in the document. 
  •  The top-level elements are not permitted to be used by specifying the xsl:apply templates. 
  •  XSLT process is provided to ignore the top-level elements and ignore some of it if an error occurs.
  •  XSLT top-element element doesn’t recognize the namespace URI and can be provided using other sources.

19.What is provided by the elements that don’t recognize the namespace URI?

  • The elements that doesn’t recognize the namespace URI provides features like:
  • The information, which is used by the extension, element or function and implemented it in an application. 
  • The information is provided regarding the work that needs to be done on the source tree.
  • The information is being provided regarding the output that needs to generate using the result tree. The metadata that needs to be gathered using the stylesheet with proper keywords and other search results.
  • The documents need to be clear and structured for the stylesheets and for its use.
20.Write a program to show Literal Result Element as Stylesheet?

  • The stylesheets consist of a single template that can be considered for the root node. 
  • The stylesheet can also consist of the literal result element that provides the output of the search made for a particular element. 
  • The stylesheet is equivalent to the stylesheet being made using the xsl:stylesheet element that consists of the template rule and the element.
  • The template rule describes to have a pattern match for the root node and the displaying properties of it. 


<html xsl:version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>Hello world</title>
</head>
<body>
<p>Hello: <xsl:value-of select="world/total"/></p>
</body>
</html>

Monday, July 15, 2013

jQuery Interview Questions & Answers

1. What Is Jquery?

  • jQuery is a JavaScript Library.
  • jQuery greatly simplifies JavaScript programming.


2. What is advantage of JQuery?

  • jQuery is a lightweight, "write less, do more", JavaScript library.
  • jQuery is easy to learn.


3. What is the purpose of Jquery?

  • The purpose of jQuery is to make it much easier to use JavaScript on your website.
  • jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
  • jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.

4. What are features of Jquery?
The jQuery library contains the following features:

  • HTML/DOM manipulation
  • CSS manipulation
  • HTML event methods
  • Effects and animations
  • AJAX
  • Utilities


5.Will jQuery work in all browsers?

The jQuery team knows all about cross-browser issues, and they have written this knowledge into the jQuery library. jQuery will run exactly the same in all major browsers, including Internet Explorer 6!

6-How can we Adding jQuery to Your Web Pages?
There are several ways to start using jQuery on your web site. You can:

  • Download the jQuery library from jQuery.com
  • Include jQuery from a CDN, like Google


7.Do you wonder why we do not have type="text/javascript" inside the <script> tag?

This is not required in HTML5. JavaScript is the default scripting language in HTML5 and in all modern browsers!

8.One big advantage of using the hosted jQuery from Google or Microsoft:

Many users already have downloaded jQuery from Google or Microsoft when visiting another site. As a result, it will be loaded from cache when they visit your site, which leads to faster loading time. Also, most CDN's will make sure that once a user requests a file from it, it will be served from the server closest to them, which also leads to faster loading time.

9.What is  Document Ready Event?
This is to prevent any jQuery code from running before the document is finished loading (is ready).

10. What are advantages for using Document Ready Event?
It is good practice to wait for the document to be fully loaded and ready before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section. actions that can fail if methods are run before the document is fully loaded:
Trying to hide an element that is not created yet
Trying to get the size of an image that is not loaded yet

11.What is jQuery Selectors?

  • jQuery selectors are one of the most important parts of the jQuery library.
  • jQuery selectors allow you to select and manipulate HTML element(s).
  • jQuery selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, values of attributes and much more. It's based on the existing CSS Selectors, and in addition, it has some own custom selectors.
  • All selectors in jQuery start with the dollar sign and parentheses: $().


12.How Can we select element using JQuery Selector?
The jQuery element selector selects elements based on the element name.
You can select all <p> elements on a page like this:

$("p")

13.What is Id Selectors.

  • The jQuery #id selector uses the id attribute of an HTML tag to find the specific element.
  • An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element.
  • To find an element with a specific id, write a hash character, followed by the id of the element:


$("#test")

14.What is Class Selectors?

  • The .class SelectorThe jQuery class selector finds elements with a specific class. 
  • To find elements with a specific class, write a period character, followed by the name of the class:
          $(".test")

15.What are Events and give some examples?

  • All the different visitor's actions that a web page can respond to are called events.
  • An event represents the precise moment when something happens.Examples.
  • moving a mouse over an elements
  • Selecting a radio button
  • clicking on an element

16.why are we used jQuery Event Methods$(document).ready()?

The $(document).ready() method allows us to execute a function when the document is fully loaded.

17 .what is jQuery Effects?
jQuery afftest are hide, Show, Toggle, Slide, Fade, and Animate. WOW!

18.what are jQuery toggle() method?
With jQuery, you can toggle between the hide() and show() methods with the toggle() method.

Shown elements are hidden and hidden elements are shown:

Example

$("button").click(function(){
  $("p").toggle();
});

19.How many types are  jQuery Fading Methods:
With jQuery you can fade an element in and out of visibility.
jQuery has the following fade methods:

  • fadeIn() 
  • fadeOut()
  • fadeToggle()
  • fadeTo()


20.what is jQuery Sliding Methods
With jQuery you can create a sliding effect on elements.
jQuery has the following slide methods:


  • slideDown()
  • slideUp()
  • slideToggle()


21.Is it possible to manipulate ALL CSS properties with the animate() method?

Yes, almost! However, there is one important thing to remember: all property names must be camel-cased when used with the animate() method: You will need to write paddingLeft instead of padding-left, marginRight instead of margin-right, and so on. Also, color animation is not included in the core jQuery library.

22. what is jQuery stop() Method?

  • The jQuery stop() method is used to stop an animation or effect before it is finished.
  • The stop() method works for all jQuery effect functions, including sliding, fading and custom animations.

23.what is jQuery Callback Functions?

  • A callback function is executed after the current effect is 100% finished.
  • JavaScript statements are executed line by line. However, with effects, the next line of code can be run even though the effect is not finished. This can create errors.
  • To prevent this, you can create a callback function.
  • A callback function is executed after the current effect is finished.


24.What is jQuery Method Chaining?

Chaining allows us to run multiple jQuery methods (on the same element) within a single statement.

25.Without jQuery, AJAX coding can be a bit tricky!
Writing regular AJAX code can be a bit tricky, because different browsers have different syntax for AJAX implementation. This means that you will have to write extra code to test for different browsers. However, the jQuery team has taken care of this for us, so that we can write AJAX functionality with only one single line of code.

26.What is The jQuery noConflict() Method?
The noConflict() method releases the hold on the $ shortcut identifier, so that other scripts can use it.

27.What is Traversing?
jQuery traversing, which means "move through", are used to "find" (or select) HTML elements based on their relation to other elements. Start with one selection and move through that selection until you reach the elements you desire.

Friday, July 12, 2013

OOPS Interview Questions & Answers

1.What is Polymorphisms?
Polymorphism means one interface and many forms. Polymorphism is a characteristics of being able to assign a different meaning or usage to something in different contexts specifically to allow an entity such as a variable, a function or an object to have more than one form.

There are two types of Polymorphism.
Compile time: function or operator overloading
Runtime: Inheritence & virtual functions

2.What is Abstract method?
Abstract method doesn't provide the implementation & forces the derived class to override the method.

3.What is Virtual method?
Virtual Method has implementation & provide the derived class with the option to override it.

4.Can Struct be inherited?

No, Struct can't be inherited as this is implicitly sealed.

5 .What is Object?

Object is anything that is identifiable as a single material item.

6.What is Class?

A Class is the generic definition of what an object is a template.

The keyword class in C# indicates that we are going to define a new class (type of object)

7.What is Static field?

To indicate that a field should only be stored once no matter how many instance of the class we create.

8.What is Static Method?

It is possible to declare a method as Static provided that they don't attempt to access any instance data or other instance methods.

9.What is Inheritance?
It provides a convenient way to reuse existing fully tested code in different context thereby saving lot of coding.

Inheritance of classes in C# is always implementation Inheritance.

10.What is Virtual keyword?

This keyword indicates that a member can be overridden in a child class. It can be applied to methods, properties, indexes and events.

11.What is New modifiers?

The new modifiers hides a member of the base class. C# supports only hide by signature.

12.What is Abstract Class?

  • Abstract class is a class that can not be instantiated, it exists extensively for inheritance and it must be inherited. There are scenarios in which it is useful to define classes that is not intended to instantiate; because such classes normally are used as base-classes in inheritance hierarchies, we call such classes abstract classes.



  • Abstract classes cannot be used to instantiate objects; because abstract classes are incomplete, it may contain only definition of the properties or methods and derived classes that inherit this implements it's properties or methods.



  • Static, Value Types & interface doesn't support abstract modifiers. Static members cannot be abstract. Classes with abstract member must also be abstract.

13.What is Sealed modifiers?

  • Sealed types cannot be inherited & are concrete.
  • Sealed modifiers can also be applied to instance methods, properties, events & indexes. It can't be applied to static members.
  • Sealed members are allowed in sealed and non-sealed classes.

14.What is an Interface?

  • An interface is a contract & defines the requisite behavior of generalization of types.
  • An interface mandates a set of behavior, but not the implementation. Interface must be inherited. We can't create an instance of an interface.
  • An interface is an array of related function that must be implemented in derived type. Members of an interface are implicitly public & abstract.
  • An interface can inherit from another interface.

15.When to use Interface over abstract class?

  • Abstract Classes: Classes which cannot be instantiated. This means one cannot make a object of this class or in other way cannot create object by saying ClassAbs abs = new ClassAbs(); where ClassAbs is abstract class.
  • Abstract classes contains have one or more abstarct methods, ie method body only no implementation.
  • Interfaces: These are same as abstract classes only difference is we can only define method definition and no implementation.
  • When to use wot depends on various reasons. One being design choice.
  • One reason for using abstarct classes is we can code common functionality and force our developer to use it. I can have a complete class but I can still mark the class as abstract.
  • Developing by interface helps in object based communication.

16.What is pure virtual function?

  • When you define only function prototype in a base class without and do the complete implementation in derived class. This base class is called abstract class and client won’t able to instantiate an object using this base class.


  • A pure virtual function is a function that must be overridden in a derived class and need not be defined. A virtual function is declared to be "pure" using the curious "=0"

syntax:
class Base {
public:
void f1(); // not virtual
virtual void f2(); // virtual, not pure
virtual void f3() = 0; // pure virtual
};

Can we specify the access modifier for explicitly implemented interface method?

No, we can't specify the access modifier for the explicitly implemented interface method. By default its scope will be internal.

17.What is Protected access modifier in C#?

  • The protected keyword is a member access modifier. It can only be used in a declaring a function or method not in the class ie. a class can't be declared as protected class.
  • A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declare this member. In other words access is limited to within the class definition and any class that inherits from the class
  • A protected member of a base class is accessible in a derived class only if the access takes place through the derived class type.

For more details see http://msdn.microsoft.com/en-us/library/bcd5672a(VS.71).aspx

18.What is Public access modifier in C#?
The public keyword is an access modifier for types and type members ie. we can declare a class or its member (functions or methods) as Public. There are no restrictions on accessing public members.

19.What is Private access modifier in C#?

  • The private keyword is a member access modifier ie. we can't explicitly declare a class as Private, however if do not specify any access modifier to the class, its scope will be assumed as Private. Private access is the least permissive access level of all access modifiers.
  • Private members are accessible only within the body of the class or the struct in which they are declared. This is the default access modifier for the class declaration.

For more details, see http://msdn.microsoft.com/en-us/library/st6sy9xe(VS.71).aspx

20.What is Internal access modifier in C#?
The internal keyword is an access modifier for types and type members ie. we can declare a class as internal or its member as internal. Internal members are accessible only within files in the same assembly (.dll). In other words, access is limited exclusively to classes defined within the current project assembly.
For more details see http://msdn.microsoft.com/en-us/library/7c5ka91b(VS.71).aspx

21.What is Protected Internal access modifier in C#?
Protected Internal is a access modifiers for the members (methods or functions) ie. you can't declare a class as protected internal explicitly. The members access is limited to the current assembly or types derived from the containing class.
Protected Internal means the method is accessible by anything that can access the protected method UNION with anything that can access the internal method.

22.Default Access modifiers in C#?
An enum has default modifier as public
A class has default modifiers as Internal . It can declare members (methods etc) with following access modifiers:
public
internal
private
protected internal
An interface has default modifier as public
A struct has default modifier as Internal and it can declare its members (methods etc) with following access modifiers:
public
internal
private
A methods, fields, and properties has default access modifier as "Private" if no modifier is specified.

23.What is method overloading?

  • Method overloading allows us to write different version of the same method in a class or derived class. Compiler automatically select the most appropriate method based on the parameter supplied.

public class MultiplyNumbers

{

    public int Multiply(int a, int b)

    {

        return a * b;

    }



    public int Multiply(int a, int b, int c)

    {

        return a*b*c;

    }  

}


To call the above method, you can use following code.
MultiplyNumbers mn = new MultiplyNumbers();

int number = mn.Multiply(2, 3) // result = 6

int number1 = mn.Multiply(2, 3, 4) // result = 24


  • You can't have a overload method with same number parameters but different return type. In order to create overload method, the return type must be the same and parameter type must be different or different in numbers.


24.What is Overriding?

  • Method overriding is a feature that allows to invoke functions (that have the same signatures) and that belong to different classes in the same hierarchy of inheritance using the base class reference. In C# it is done using keywords virtual and overrides .For more information visit http://www.codeproject.com/KB/cs/cs_methodoverride.aspx


25.What is Method overloading?
Method overloading occurs when a class contains two methods with the same name, but different signatures.

26.What is Method Overriding? How to override a function in C#?

  • Use the override modifier to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.
  • You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.


27.Can we call a base class method without creating instance?
Yep. But ..

  •  Its possible If its a static method.
  •  Its possible by inheriting from that class also.
  • Its possible from derived classes using base keyword.

28.In which cases you use override and new base?
Use the new modifier to explicitly hide a member inherited from a base class. To hide an inherited member, declare it in the derived class using the same name, and modify it with the new modifier.

29.Difference between new and override keyword?

Let me explain this through code.

using System;

using System.Data;

using System.Text;

using System.Windows.Forms;



namespace BaseDerive

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void Form1_Load(object sender, EventArgs e)

        {



            BaseClass b = new BaseClass();

            b.func1();



            DeriveClass d = new DeriveClass();

            d.func1();



            //Calls Base class function 1 as new keyword is used.

            BaseClass bd = new DeriveClass();

            bd.func1();



            //Calls Derived class function 2 as override keyword is used.

            BaseClass bd2 = new DeriveClass();

            bd2.func2();



        }

    }



    public class BaseClass

    {

        public virtual void func1()

        {

            MessageBox.Show("Base Class function 1.");

        }



        public virtual void func2()

        {

            MessageBox.Show("Base Class function 2.");

        }



  public void func3()

        {

            MessageBox.Show("Base Class function 3.");

        }

    }



    public class DeriveClass : BaseClass

    {

        public new void func1()

        {

            MessageBox.Show("Derieve Class fuction 1 used new keyword");

        }



        public override void func2()

        {

            MessageBox.Show("Derieve Class fuction 2 used override keyword");

        }



public void func3()

        {

            MessageBox.Show("Derieve Class fuction 3 used override keyword");

        }



    }

}



This is a window application so all the code for calling the function through objects is written in Form_Load event.
As seen in above code, I have declared 2 classes. One works as a Base class and second is a derieve class derived from base class.

Now the difference is

new: hides the base class function.
Override: overrides the base class function.

BaseClass objB = new DeriveClass();


If we create object like above notation and make a call to any function which exists in base class and derive class both, then it will always make a call to function of base class. If we have overidden the method in derive class then it wlll call the derive class function.

For example…

objB.func1(); //Calls the base class function. (In case of new keyword)

objB.func2(); //Calls the derive class function. (Override)

objB.func3(); //Calls the base class function.(Same prototype in both the class.)

Note:
// This will throw a compile time error. (Casting is required.)
DeriveClass objB = new BaseClass();


//This will throw run time error. (Unable to cast)
DeriveClass objB = (DeriveClass) new BaseClass();
30.What is a private constructor? Where will you use it?

  • When you declare a Constructor with Private access modifier then it is called Private Constructor. We can use the private constructor in singleton pattern.
  • If you declare a Constructor as private then it doesn’t allow to create object for its derived class, i.e you loose inherent facility for that class.

Example:

Class A

{

// some code

 Private Void A()

 {

 //Private Constructor

 }

}



Class B:A

{

//code

}



B obj = new B();// will give Compilation Error

Because Class A constructor declared as private hence its accessibility limit is to that class only, Class B can't access. When we create an object for Class B that constructor will call constructor A but class B have no rights to access the Class A constructor hence we will get compilation error.

31.Can we declare private class in a Namespace?

No. If you try to create a private class in a Namespace, Compiler will throw a compile time error “Namespace elements cannot be explicitly declared as private, protected, or protected internal”.

Reason: The message says it all. Classes can only be declared as private, protected or protected internal when declared as nested classes, other than that, it doesn't make sense to declare a class with a visibility that makes it unusable, even in the same module. Top level classes cannot be private, they are "internal" by default, and you can just make them public to make them visible from outside your DLL.

32.What is Polymorphism?
In OPP’S, polymorphism(Greek meaning “having multiple forms”) is the ablity of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a a function, or an object to have more than one forms.

In C# :
Parent classes may define and implement “virtual” methods(Which is done using the “virtual” keyword), and derived classes can override them(using the “override” keyword), which means they provide their own definition and implementation.At run-time, when user’s code calls the method, the CLR looks up the run-time type of the object, and invokes that override of the virtual method. Thus in your source code when a method of the base class is called it executes the overriden method.

23.What Are Attributes in DotNet?

  • An Attribute is a declarative tag which can be used to provide information to the compiler about the behaviour of the C# elements such as classes and assemblies.
  • C# provides convenient technique that will handle tasks such as performing compile time operations , changing the behaviour of a method at runtime or maybe even handle unmanaged code.
  • C# Provides many Built-in Attributes

Some Popular ones are

- Obsolete
- DllImport
- Conditional
- WebMethod

34.What can you do to make class available for inheritance but you need to prevent it's method to come in inheritance chain?

Well, Declare a class with public access specifier and mark all it's method to sealed . As anything which is declared with sealed keyword cannot be inherited.

35.What's the Difference between Interface and Abstract Class
Abstract Class:
Have constructors.
Not necessarily for the class inheriting it to Implement all the Methods.
Doesn't Support Multiple Inheritance.

Where everything is Opposite in the Interfaces.

36.What are the various types of Constructors

  • Public : Accessible to All
  • Private: Those classes in which only static members are there and you don't want there objects to be created in any class.
  • Static: Used for initializing only the static members of the class. These will be invoked for the very first time the class is being loaded on the memory. They cannot accept any arguments. Static Constructors cannot have any access modifiers.
  • Intern: implementations of the abstract class to the assembly defining the class. A class containing an internal constructor cannot be instantiated outside of the assembly (Namespace).
  •  External

37.What are Constructors ?

  • Constructors are used for initializing the members of a class whenever an object is created with the default values for initialization.
  • If no constructor defined then the CLR will provide an implicit constructor which is called as Default Constructor.
  • A class can have any number of constructors provided they vary with the number of arguments that are passed, which is they should have different signatures.
  • Constructors do not return a value
  • Constructors can be overloaded

38.When to Use Abstract Classes and When Interfaces.

If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.

If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.

If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.

If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.

39.Diversities between an abstract method & virtual method ?

An Abstract method does not provide an implementation and forces overriding to the deriving class (unless the deriving class also an abstract class), where as the virtual method has an implementation and leaves an option to override it in the deriving class. Thus Virtual method has an implementation & provides the derived class with the option of overriding it. Abstract method does not provide an implementation & forces the derived class to override the method.

40.What is Early binding and late binding?

Calling a non-virtual method, decided at a compile time is known as early binding. Calling a virtual method (Pure Polymorphism), decided at a runtime is known as late binding.

41.Difference between ASP Session and ASP.NET Session?
Asp.net session supports cookie less session & it can span across multiple servers.

42.Illustrate Server.Transfer and Response.Redirect?

Server.Transfer, transfers the control of a web page, posting a form data, while Response.Redirect simply redirects a page to another page, it can not post a form data to another page. Server.Transfer is more efficient over the Response.Redirect, because Response.Redirect causes a round trip to server as the page is processed once again on the client and a request is made to server there after.
But the browser url is not changed in case of Server.Transfer i.e. Browser history is not modified in using it.

43.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.

44.What does the keyword virtual mean in the method definition?
The method can be over-ridden.

45.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.

46.Can you override private virtual methods?


No, you cannot access private methods in inherited classes.

Can you prevent your class from being inherited and becoming a base class for some other classes?

47.
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.

48.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.

49.Why can't you specify the accessibility modifier for methods inside the interface?

you are not allowed to specify any accessibility, it's public by default.

50.Static datamembers should be initialized inside the constructor. True or False.

False. Static datamembers should not be initialised inside constructor.

51.Static methods can not use non static members. True or False.
True

52.A constructor can be private. True or False
True. A constructor can be private. We can declare a constructor as private.

53.What is the work of a constructor?
Constructor creates and initialises the objects in an application.

54.Name the operators that cannot be overloaded.

sizeof
.
.*
.->
::
?:



56.What is "this" pointer?

This pointer is a pointer which points to the current object of a class. this is actually a keyword which is used as a pointer which differentiate the current object with global object.
57.public class Base { public virtual void foo(int x) { Console.WriteLine("Base foo(int)"); } } public class Derived: Base { public void foo(int x) { Console.WriteLine("Derived foo(int)"); } } class Program { static void Main(string[] args) { Derived d = new Derived(); int i = 10; d.foo(i); } }


NOTE: This is objective type question, Please click question title for correct answer.

58.Difference between sealed and static classes

sealed classes:

1)we can create their instances, but cannot inherit them

ex:

sealed class demo
{

}

class abc:demo
{
--Wrong
}
2)They can contain static as well as nonstatic members.

static classes:

1)we can neither create their instances, nor inherit them

ex:
static class Program
{

}

2)They can have static members only.

59.Differences between a structure and class

Structure:

1)It is a Value Type
2)Its variable directly contains the data on the stack
3)Each structure variable has its independent copy
of data.
4)One structure cannot inherit other
5)They do not have destructors
6)They do no have explicit parameterless constructors
7)we cannot put sealed /abstract modifiers before the structures.
8)Easier memory management
9)examples:
int, short,long,DateTime,
Point
(predefined)

Uses:
Structures are typically used for handling
small amounts of data or where inheritance, overriding is not required
example: int a=100;


Class

1)It is a reference Type
2)Its variable has references to the data(data is stored in the object created in the heap) .
3)Two Class variables can refer to the same object
4)One class can inherit the other(unless the class is sealed/static)
5)Classes have destructors
6)They can have explicit parameterless constructors
7)Sealed/abstract modifers can be put before classes.
8) Comparitively Difficult memory management
9)example: SqlConnection,DataView(predefined classes)

Classes are typically used where inheritance, overriding is required
or we need to create objects capable of handling large data
example: DataSet,ArrayList can handle large data.

Thursday, July 11, 2013

Silverlight Interview Questions & Answers

1. What is Microsoft Silverlight?
  • Silverlight is a web based technology, launched by Microsoft in April 2007. Silverlight is considered as a competitor to Adobe's Flash.
  • Silverlight is Microsoft's implementation of a cross-browser, cross-platform client framework that allows designers and developers to  deliver Rich Internet Applications (RIA) embedded in Web pages.
  • Silverlight is a browser plug-in approximately 6MB in size; it is client-side free software, with an easy and fast (less than 10 sec) one time installation available for any client side browser.
  • It supports advanced data integration, multithreading, HD video using IIS Smooth Streaming, and built-in content protection.
  • Silverlight enables online and offline applications for a broad range of business and consumer scenarios.
  • One of the design goals of the Silverlight technology is to fill the gap between Windows applications and Web applications in terms of creating Graphical User Interfaces (GUI).
  • Silverlight applications are run as client-side applications without the need to refresh the browser to update the UI. However,because of the built-in .NET framework, Silverlight applications can easily integrate with server-side controls and services. UsingSilverlight's implementation of the .NET framework, developers can easily integrate existing libraries and code into Silverlight applications.
2    Why use Silverlight?
  • Support for the .NET Framework – if you are already a .NET developer, it is easy to start programming on Silverlight.
  • Support for managed code – you can write programs in your favorite language which .NET CLR supports like C#, VB.NET, dynamic languages (IronPython, IronRuby).
  • Better development tools -Visual Studio 2010, Expression Blend.
  • Large community-  More learning resources available compared to Flash.
  • Integration with Enterprise based technologies like WPF, LINQ etc…
  • Silverlight integrates the XAML declarative language with the .NET framework.
  • It is a cross-browser, cross-platform technology which provides a consistent user experience everywhere it runs.
  • The Silverlight plug-in installs in seconds, and leaves a very small footprint.
  • After you install the plug-in, users no longer need to install anything on their workstations to run Silverlight applications.
  •  The applications are available to them from whatever browser they are accessing.
  • It runs a client-side application that can read data and update the UI without interrupting the user by refreshing the whole page.
  • It can run asynchronous communications with the server, allowing the UI to continue to function while waiting for the server response.
  • It delivers rich video, audio, and graphics.
3. Which platforms does Silverlight support?

  • Mac OS
  • Windows Vista
  • Windows XP SP2
  • Windows 2000
  • Windows Server 2003
  • Linux (Moonlight)
  • Question 4. Which browsers does Silverlight support?
  • Answer : Microsoft  - Internet Explorer 6, 7, 8
  • Mozilla  - Firefox 2 and 3
  • Apple  - Safari 3 and 4
  • Google  - Chrome

5. What are the system requirements for Silverlight?
  • The system requirements for Microsoft Silverlight and associated technologies are listed below.Windows

  • Operating System: Windows 7, Windows Vista, Windows XP Service Pack 2 Intel® Pentium® III 450MHz or faster processor (or equivalent) 128MB of RAM
  • Mac OS Operating System: Apple Mac OS X 10.4.8 or above Intel Core™ Duo 1.83GHz or faster processor 128MB of RAM
  • Linux
  • Moonlight
 6. What is Moonlight?
  • Moonlight is an Open Source implementation of Silverlight, primarily for Linux and other Unix/X11 based Operating Systems. In
  • September of 2007, Microsoft and Novell announced a technical collaboration that includes access to Microsoft's test suites for
  • Silverlight and the distribution of a Media Pack for Linux users that will contain licensed media codecs for video and audio.
  • Moonlight 2 was released December 17, 2009

 7. What are the goals of Moonlight?
  • To run Silverlight applications on Linux.
  • To provide a Linux SDK to build Silverlight applications.
  • To reuse the Silverlight engine built for desktop applications.

 8. Is Silverlight free?
   Yes, Microsoft has made the Silverlight browser plug-in freely available for all supported platforms and   browsers.

 9. What is the difference between Silverlight 1.0 and 2?
  • Silverlight 1 is purely AJAX and JavaScript based. All the code has to be written in JavaScript and XAML.
  • Silverlight 2 supports managed code. When the Silverlight 2 runtime is installed, it installs a limited version of the .NET runtime on the client machine. This allows .NET programmers to write managed code to be executed on the client PC, and provides a better user experience to users. Of course, there is security restrictions built in to it so that the code has limited access to the client computer.
  • The biggest change is the implementation of the .NET Framework. If you are familiar with Silverlight 1.0, then you will be used to coding the application functionality in JavaScript. You can still implement functionality using JavaScript; however, you can now also implement functionality using C#, Visual Basic, Python, Ruby, and managed JavaScript.
  • Another major change is the introduction of the XAP package. In Silverlight 1.0, the XAML code was referenced directly by the


  • Silverlight object embedded in the browser. In Silverlight 2, however, the embedded object references an XAP package that contains the XAP file, assemblies, and resources necessary to run the Silverlight application.


 10. What is the Silverlight plug-in?
  • The Silverlight plug-in is a very lightweight component that is necessary for users to access Silverlight applications. The plug-in download and install takes only a few moments, and do not take up much hard drive space.
  • The Silverlight plug-in is responsible for accessing the Silverlight object in the Web page, downloading and accessing the XAP package, setting up the program environment, and beginning execution of the application.
  • When a Web page containing a Silverlight application is displayed, the user should be given a link to download the plug-in from
  • Microsoft if the plug-in is not already installed.


11. What is Silverlight Runtime?
Silverlight Runtime is a browser plug-in to support Silverlight enabled applications. If the Silverlight runtime is not installed, browsers will not be able to run Silverlight elements in the browser. You can set up your Silverlight tags in such a way that your browser will automatically prompt the user to download and install the Silverlight plug-in when your application is launched in the browser.
Installing the run time is a onetime operation on the client. Once installed, it will be automatically launched when any Silverlight application is loaded in the browser.

Note: Silverlight plug-in and the runtime, both are the same; however, I am giving two definitions here.

12. What is Silverlight SDK?
Silverlight SDK is a set of tools, documentation, samples, and templates for web developers to enable them to easily develop Silverlight enabled applications. The SDK is not really mandatory to develop Silverlight applications; however, the SDK will make development much easier.

 13. What are the tools required to develop Silverlight applications?
  • To run Silverlight applications in a web browser, you need to have the Silverlight runtime installed on the client browser as a plug-in. This is a light-weight version of the .NET runtime.

  • However, to develop a Silverlight application, you need something more.

  • Silverlight SDK: This includes a set of tools required to compile and build Silverlight controls.

  • If you are comfortable writing HTML using Notepad and compiling .NET applications from console tools, then you just need the Silverlight SDK to develop Silverlight applications.
  • However, most people use some kind of IDE to develop applications faster.
  • Microsoft offers two separate tools to develop Silverlight applications:
  • Microsoft Expression Studio - This tool is meant for web designers to create rich visual elements for Silverlight applications.
  • Expression Studio is recommended for web designers who create rich internet applications with enhanced visual content and graphics.
  • There are several features provided for creating enhanced graphics elements, with lot of options to pick color, font, etc.
  • Microsoft Visual Studio - This is the integrated development environment from Microsoft to develop .NET applications. Programmers can use Visual Studio to develop Silverlight applications which require programming. Visual Studio allows programmers to develop sophisticated Silverlight applications in any .NET language (like C#, VB.NET etc).
  • Here are some other tools that you can use:
  • Install Deep Zoom Composer - This tool allows you to prepare your images for use with the Deep Zoom feature in Silverlight 3.
  • Download Silverlight Toolkit - This toolkit is a Microsoft project containing Silverlight controls, components, and utilities that can be downloaded and used in your Silverlight applications. It includes full source code, samples, and tests.
  • Download .NET RIA Services - Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes, and custom operations.


14. Which tool to use - Expression Studio or Visual Studio?
If your Silverlight application includes just graphics and visual elements, then you can use Expression Studio. However, if you are a programmer and if your Silverlight application includes programming logic, then you might want to choose Visual Studio.

15. What are the Silverlight versions available so far?

  • Silverlight 1.0: Silverlight 1.0, which was developed under the codename Windows Presentation Foundation/Everywhere (WPF/E), consists of the core presentation framework which is responsible for the user interface (UI), interactivity, and user input, basic UI controls, graphics and animation, media playback, Digital Restrictions Management (DRM), and DOM integration.
  • Silverlight 2: Silverlight 2 (previously referred to as version 1.1) includes a version of the .NET Framework, mplementing the same full Common Language Runtime (CLR) version as .NET Framework 3.0. The XAML markup as well as the code is compiled into .NET assemblies which are then compressed using Zip and stored in a .xap file.
  • Silverlight 3: Silverlight version 3 was released in July 9, 2009, which is an extension to Silverlight 2.0, and mainly provides improvements in graphics capabilities, media management, application development areas (additional controls, enhanced binding support, and out-of-browser functionality), and integration in the designers' Expression Blend 3 tools.
  • Silverlight 4: Silverlight version 4 was released on April 15, 2010 (along with Silverlight 4 tools for developers).


 16. What is a .xap file?

  • A .xap file is a Silverlight-based application package (.xap) that is generated when the Silverlight project is built. A .xap file is the compressed output file for a Silverlight application. The .xap file includes AppManifest.xaml, the compiled output assembly of the Silverlight project (.dll), and the resource files referred to by the Silverlight application:

  • Web pages like .aspx files and .html files use Silverlight components by loading .xap files using the <object> tag in HTML or by using the <asp:Silverlight> tag in ASP.NET pages.
  • ".xap" files (pronounced "zap") use the standard Zip compression algorithm to minimize client download size.
  • Rename this file to SilverlightTest.zip and open it using any decompression tool. You can see that this is just like any other zip file, and it includes the project's output DLL and another file called "AppManifest.xaml".


17. How does XAP work?
Once you have created the .xap file (explained below), the Silverlight 2 plug-in downloads the file and runs it in a separate work space.

18. How do I use a .xap file?
A .xap file is used to contain and transfer the assemblies and resources of a managed code application. This managed code application must be run within the Silverlight 2 browser plug-in.

 19. Can we add a reference to a Class Library project in a Silverlight application project?
No, you can't add a reference to a Class Library project to a Silverlight application project. You can only add the reference of another Silverlight application project inside a Silverlight application project.

However, you can add a reference to a Web Service or WCF Service.

 20. What is a Silverlight.js file?
Silverlight.js is a helper file which enables websites to create advanced Silverlight installation and instantiation experiences. You can call the createObject and createObjectEx functions defined in this file to embed the Silverlight plug-in in a web page.

 21. What is the use of the ClientBin folder?
The ClientBin folder is used to place the .xap file of a Silverlight application. You can keep it anywhere in your web application, but this is the default location used by Silverlight.

 22. How to change the default page of a Silverlight application?
To change the default page of a Silverlight application, you need to set the RootVisual property inside the Application_Startup event of the App.xaml file.

private void Application_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = new MainPage();
}

 23. What is XAML?
XAML stands for eXtended Application Markup Language. XAML contains XML that is used to declaratively specify the user interface for Silverlight or WPF applications. For example, if you need to display a rectangle, this is the XAML you need to use:
<UserControl x:Class="SilverlightApplication1.SilverlightControl1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Width="400" Height="300">
    <Canvas Width="500" Height="500" Background="White">
        <Rectangle Canvas.Left="75" Canvas.Top="90"
                  Fill="red" Width="100" Height="100" />
    </Canvas>
</UserControl>


When the above XAML is executed, it will display a rectangle filled with red color. You may notice that XAML is very similar to HTML in nature.
XAML stands for eXtensible Application Markup Language, and is a declarative markup language that follows the XML rule and is used for developing User Interfaces in WPF and Silverlight technology. XAML files are XML files that generally have the .xaml extension, and separates the UI definition from the run-time logic by using code-behind files, joined to the markup through partial class definitions.
XAML has a set of rules that map object elements into classes or structures, attributes into properties or events, and XML namespaces to CLR namespaces. XAML elements map to Microsoft .NET types as defined in referenced assemblies, and the attributes map to members of those types.

 24. What is the AppManifest.xml file?
First, let’s look at an example AppManifest.xaml file:
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  EntryPointAssembly="SilverlightApplication1"
  EntryPointType="SilverlightApplication1.App"
  RuntimeVersion="2.0.30226.2">
    <Deployment.Parts>
        <AssemblyPart x:Name="SilverlightApplication1"
           Source="SilverlightApplication1.dll" />
        <AssemblyPart x:Name="System.Windows.Controls"
           Source="System.Windows.Controls.dll" />
        <AssemblyPart x:Name="System.Windows.Controls.Extended"
           Source="System.Windows.Controls.Extended.dll" />
    </Deployment.Parts>
</Deploymnt>
The first element in AppManifest.xaml is a Deployment node. This node defines the application, and contains the child AssemblyPart nodes.

As you can see the AssemblyPart nodes define what assemblies (DLLs) are contained within the .xap file, and give each of them a name.

Now, if you look back up to the top, you'll see the Deployment node has the EntryPointAssembly and EntryPointType attributes.
The EntryPointAssembly attribute defines which assembly defined below (as a child AssemblyPart node) is the main assembly (DLL) for the application. And, the EntryPointType attribute specifies the class contained within the assembly (DLL), defined in the EntryPointAssembly attribute, is the main class that will be instantiated to start the application.

The Deployment node also has a RuntimeVersion attribute that defines the version of Silverlight the application is built for.

25. What files are contained within the .xap file?

The .xap file contains an application manifest (AppManifest.xaml) file and all the necessary DLLs that are required by the application. The first DLL contained is the compiled version of your application and has the same name of your application. In my test, I created an application named "SilverlightApplication1", so the DLL is named "SilverlightApplication1.dll". The rest of the

DLLs are the dependencies the application requires.

 26. What is app.xaml?

App.xaml is a file used by Silverlight applications to declare shared resources like brushes, various style objects, templates etc. Also, the code-behind file of app.xaml.cs is used to handle global application level events like Application_Startup, Application_Exit, and Application_UnhandledException (similar to the Global.asax file for ASP.NET applications).
When Visual Studio creates the app.xaml file automatically, it creates a few event handlers with some default code. You can change the code appropriately.

private void Application_Startup(object sender, StartupEventArgs e)
{
}

private void Application_Exit(object sender, EventArgs e)
{
}

private void Application_UnhandledException(object sender,
             ApplicationUnhandledExceptionEventArgs e)
{
}
For ASP.NET developers, the above code will look familiar. This is similar to the application level event handlers in Global.asax.

 27. What is the Silverlight official name?

Silverlight was formerly code-named "WPF/E".

 28. What are the main features and benefits of Silverlight?

  • Compelling cross-platform user experiences.
  • Flexible programming model with collaboration tools.
  • High-quality media, low-cost delivery.
  • Connected to data, servers, and services.


29. What is MainPage.xaml?

Answer :When you create a Silverlight project using Visual Studio, it creates a default XAML file called "MainPage.xaml". This is just a dummy start page created by Visual Studio, and it does not contain any visible UI elements. The default contents of the MainPage.xaml file looks like this:

<UserControl x:Class="SilverlightApplication1.MainPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    </Grid>
</UserControl>

 30. Which language is Silverlight developed in?

It was developed using a combination of C# and C++.

 31. Can I consume WCF and ASP.NET Web Services in Silverlight?

Answer :Yes, you can.

 32. What are Deep Zoom and Deep Zoom Composer?


  • Deep Zoom provides the ability to interactively view high-resolution images in Silverlight. You can zoom in and out of images rapidly without affecting the performance of your application. Deep Zoom provides smooth in-place zooming and panning.


  • DeepZoom Composer allows you to create high resolution image compositions which are built for smooth zooming and panning. DeepZoom Composer is absolutely free, and is simple to use - just loads in all your high resolution images and makes your composition on screen.


  • Deep Zoom Composer is a tool that allows preparing of images for use with the Deep Zoom feature in Silverlight 3.


 33. What is the difference between WPF and Silverlight?

  • Silverlight and Windows Presentation Foundation (WPF) are two different products from Microsoft, but have lot of overlap.
  • Silverlight is a subset of WPF in terms of features and functionality.


  • Silverlight is a Microsoft technology, competing with Adobe's Flash, and is meant for developing rich browser based internet applications.


  • WPF is a Microsoft technology meant for developing enhanced graphics applications for the desktop platform. In addition, WPF applications can be hosted on web browsers which offer rich graphics features for web applications. Web Browser Applications (WBA) developed on the WPF technology uses XAML to host user interfaces for browser applications. XAML stands for eXtended Application Markup Language, which is a new declarative programming model from Microsoft. XAML files are hosted as discrete files in the Web server, but are downloaded to the browsers and converted to a user interface by the .NET runtime in the client browsers.


  • WPF runs on the .NET runtime, and developers can take advantage of the rich .NET Framework and WPF libraries to build really cool Windows applications. WPF supports 3-D graphics, complex animations, hardware acceleration etc.


  • Silverlight uses a particular implementation of a XAML parser, with that parser being part of the Silverlight core installation. In some cases, the parsing behavior differs from the parsing behavior in Windows Presentation Foundation (WPF), which also has a particular implementation.

In table format:
Silverlight WPF
Definition

  • Silverlight is Microsoft’s latest development platform for building next-generation Web client applications.


  • Windows Presentation Foundation (WPF) is Microsoft’s latest development platform for building next-generation Windows client applications.Subset of Silverlight is generally considered to be a subset of WPF, and is a XAML-based technology that runs within the sandbox of a browser plug-in.


  • WPF is generally considered to be a subset of .NET Framework, and is a XAML based technology.

GUI

  • Silverlight will be used in the development of  Rich Internet Applications (RIA) for web client users.


  • WPF will be used in the development of Rich Windows Graphical User Interfaces (GUI) for Windows client users.

Support

  • Cross OS, cross browser, cross device.


  • Windows only.


  • Software Required


  • Silverlight is the add-on mechanism available for most browsers; in order to run Silverlight applications at client machines, we need to install Silverlight software on the client machine once.


  • WPF, on the other hand, does not support any plug-in mechanism; instead, we need to install a completed WPF client application in order to use the WPF application at the client place.

Framework support

  • Silverlight has a very small, its own rich base class library to make the plug-in as small as possible. It is highly optimized for size, and is a small subset of the full .NET Framework, to be embedded within an application.


  • WPF, on the other hand, has full access to the main .NET Framework and all its associated assemblies.

Deployment

  • Silverlight applications are hosted within a web server and a web page. To minimize client download size, Silverlight uses a XAP archive. A XAP archive is a zip-compressed archive of the Silverlight application, plus a manifest file describing the content.


  • Visual Studio automatically generates the XAP archive when using the Silverlight project template.


  • WPF applications can be deployed as standalone applications, ClickOnce applications, or XAML browser applications.


34. What is the difference between Silverlight and Flash?

  • Adobe Flash is the most popular competitor to Silverlight, supporting browser plug-ins and enabling the execution of rich content for the Web. Flash is not a new technology, and already has had a long life span as compared to Silverlight. But it does not have a huge community as expected; it may be because of the limited development tools which are not known to most developers.  Flash uses ActionScript as the programming language and Flex as the programming environment, and most developers are far from these technologies.
  • For ASP.NET developers, to extend their websites using Flash content is not so simple. They need to learn a development environment like ActionScript and Flex. Apart from that, there is no way to generate Flash content using server-side .NET code, which means it’s difficult to integrate ASP.NET content and Flash content.


  • Silverlight aims to give .NET developers a better option for creating rich web content. Silverlight provides a browser plug-in with many similar features to Flash, but one that’s designed from the ground up for .NET. Silverlight natively supports the C# language, and uses a range of .NET concepts. As a result, developers can write client-side code for Silverlight in the same language they use for server-side code (such as C# and VB), and use many of the same abstractions (including streams, controls, collections, generics, and LINQ).


 35. What is the difference between Silverlight and ASP.NET AJAX?

Microsoft ASP.NET AJAX, a set of JavaScript libraries built into ASP.NET 3.5, is available as a separate download for ASP.NET

2.0. Being an integral part of ASP.NET 3.5 and the AJAX Controls Toolkit for ASP.NET 3.5, now ASP.NET AJAX client-and server-side libraries are more integrated with Visual Studio 2008. The client-side library allows you to implement client-level processing such as processing and validating information entered by the end user, refreshing a portion of the web page, and developing rich, interactive user interfaces. You can also efficiently integrate the client-side library components with the server-side ASP.NET controls library in asynchronous mode. The key technology driver of ASP.NET AJAX is scripting. In general, script-based web applications face several challenges due to different browser settings (e.g., JavaScript is not enabled by default) on PCs and mobile devices. As a result, scripting is often not always the best strategy for enterprises to use to develop secure and scalable RIAs.

ASP.NET AJAX supports limited features of RIAs, and does not support effective multimedia integration, managed code-behind integration, or metadata and information management. Microsoft ASP.NET AJAX is a widely accepted model for building RIAs, but it is very likely that, having Silverlight as an option, .NET developers will migrate ASP.NET AJAX applications to Silverlight RIAs. Visit
www.asp.net/ajax/ if you want to learn more about Microsoft ASP.NET AJAX.

 36. What are the different Layout controls available in Silverlight?
There are three different types of Layout controls provided by Silverlight:

  • Canvas - Position child elements absolutely in x, y space.
  • StackPanel - Position child elements relative to one another in horizontal or vertical stacks.
  • Grid - Position child elements in rows and columns.

You have to add a layout panel to every XAML page you create. All other UI elements must be added inside one of the layout panels.

Each page can have exactly one layout panel control.

 37. Are XAML files compiled or built at runtime?

XAML files are usually compiled rather than parsed at runtime. But it also supports parsing during runtime. When we build a XAML based project, you will see it creates a g.cs extension in the obi\Debug folder. Therefore, for every XAML file, you will find a g.cs file. For instance, a MainPage.XAML will have a MainPage.g.cs file in the obi\Debug folder. In short, at run time, you actually do not see the XAML file. But if you want to do runtime parsing of the XAML file, it also allows that to be done.

 38. What is the long-term goal or vision for Silverlight?

  • Microsoft Silverlight is a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web.
  • Silverlight offers a flexible programming model that supports AJAX, VB, C#, IronPython, and IronRuby, and integrates with existing Web applications.
  • By using Expression Studio and Visual Studio, designers and developers can collaborate more effectively using the skills they have today to light up the Web of tomorrow.
  • By leveraging Silverlight's support for .NET, High Definition video, cost-effective advanced streaming, unparalleled high-resolution interactivity with Deep Zoom technology, and controls, businesses can reach out to new markets across the Web, desktop, and devices.


 39. Do I need to have the .NET Framework installed in order to use Silverlight?

The answer to this is no - a cross platform version of the .NET Framework is included in the 6 MB Silverlight 4 download, which means you do not need to have anything extra installed on the client in order to access Silverlight applications in the browser.

The Silverlight version of the .NET framework includes the same CLR engine (same GC, type-system, JIT engine) that ships with the full .NET Framework, and a subset of the .NET Framework namespace libraries. You can see the full list of all classes/namespaces that are included by opening up the Object Browser when you create a new Silverlight application using Visual Studio.

40. What are the other RIA technologies besides Silverlight?

Adobe Flex, Java FX, Adobe Flash are some of the other RIA technologies besides Silverlight.

41. What is meant by RIA?

RIA stands for Rich Internet Applications, which are Web applications with rich user interfaces including media elements such as audio, video etc. You can think of them as being similar to powerful and rich desktop applications, except that RIA applications are Web based.

 42. What is .NET RIA Services?
Microsoft .NET RIA Services helps to simplify the n-tier application pattern by combining the ASP.NET and Silverlight platforms. RIA Services provides a pattern using which you can write application logic that can run on the mid-tier and controls access to data for queries, changes, and custom operations. It also provides support for data validation, authentication, and roles by integrating with Silverlight components on the client and ASP.NET on the middle tier.

 43. What are the design files and the code-behind files in Silverlight?
The user interface elements of Silverlight applications are defined in XAML files. The logic and functionality of Silverlight applications is implemented using managed NET code-behind files that share the same class with the XAML file.

 44. Who is using Silverlight?
Yahoo! Japan, NBC, Continental Airlines, NASA, Indian Premier League, and National Instruments are some of the organizations currently using Silverlight to enhance their businesses.

 45. What features are missing from Silverlight presentation markup that will be supported in WPF?
Some high-end Windows specific features of WPF, such as real 3D, hardware-based video acceleration, and full document support, will not be supported in Silverlight. This is by design in order to serve Silverlight’s cross-browser, cross-platform reach scenario that demands a light weight plug-in. That being said, Silverlight will offer a uniform runtime that can render identical experiences across browsers on both Mac OS and Windows.

 46. Will I need more memory, a faster processor, or a better Graphics Processing Unit (GPU)?
Microsoft designed Silverlight with the ability to deliver high-fidelity experiences on the broadest set of system configurations. Some features, such as HD video, may benefit from the power contained in newer personal computers.

47. How does Silverlight make the Microsoft development system better?
Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of media experiences and rich interactive applications (RIAs) for the Web. Examples include:

For ASP.NET-based Web applications, Silverlight provides a rich UI front-end that, with a consistent programming model, adds support for richer interactivity, media, and audio.
For Microsoft SharePoint–based content, Silverlight offers the ability to create rich Web Parts.
For Windows Live services, Silverlight offers the ability to consume services and APIs more effectively.

 48. What is the relationship and difference between Silverlight and ASP.NET?
Technically, Silverlight and ASP.NET are completely different. The major differences are listed below:
Silverlight runs completely on the client, while ASP.NET mainly runs on the server, but also has a few parts running on the client.
When an event fires, Silverlight handles the event on the client, but in ASP.NET, the browser will make an HTTP POST to the server, and after the server handles the request, it sends a new HTML page to the client.
A Silverlight application sends rendering commands to the Silverlight rendering engine by either writing XAML or code, and the Silverlight rendering engine will handle the rendering task. On the other hand, ASP.NET doesn’t have a rendering engine. It generates an HTML file on the server, sends it to the client, and allows the browser to parse the HTML file and render the content.
Silverlight can’t work with a database directly; instead, it consumes data from Web Services, while ASP.NET has strong support for working with databases directly.
The most important thing to note is what runs on the client and what runs on the server, since this will affect almost every part of your system. Silverlight runs on the client, and ASP.NET runs on the server. They can work together and are compatible with each other, but this requires some time and effort.

49. When to use Silverlight, ASP.NET, or both?
This depends on different scenarios. Below are some common approaches:
Pure Silverlight
One approach is to completely remove ASP.NET. This solution works best if you’re working on a new development. You only need to work on Silverlight, without any worry about integration problems. If you need to communicate with the server, you write Web Services, such as WCF. It will also help you when you need to port part or whole of your system to another hosting or even another platform, since the client and the server are completely separate.

Major ASP.NET, plus a Silverlight island
This approach is generally used when the Silverlight content and the ASP.NET content have little relationship. For example, an ASP.NET blog engine with a Silverlight media player in a blog post. This approach is very easy to implement, and allows you to reach the broadest audience. For example, if a user hasn’t installed Silverlight, he can still read the blog posts, but he can’t watch the videos.

Use ASP.NET AJAX instead of Silverlight
ASP.NET AJAX is designed to work with ASP.NET. It is mainly an extension to ASP.NET. While AJAX can’t provide you the advanced user experience that Silverlight can, for many scenarios, it should be sufficient. This approach also helps if you have strong ASP.NET experience, but are still quite new to Silverlight.

Within this approach, there are two branches. One is to mix the client and server code by using the UpdatePanel, AJAX Control

Toolkit, and etc. The other method is to take the pure AJAX approach, where you write HTML and JavaScript instead of using server controls, and call Web Services to communicate with the server. The former branch is easier to implement, especially if you have strong ASP.NET experience but lack JavaScript knowledge. The latter branch proves to be better in an architecture when you want to port an AJAX application to other technologies such as Silverlight, especially since you only need to rewrite the client side code, and can keep the Web Services as they are. The programming model for the latter branch is similar to Silverlight. Therefore, this approach is rarely taken if you’re experienced in Silverlight.

Mix Silverlight with ASP.NET
More often, you may want to port an existing ASP.NET application to Silverlight, but you don’t want to completely rewrite the entire application. This is the most difficult approach since you’re mixing client side and server side technologies.
Before going with this approach, please consider if the above approaches can solve your problem. Ask yourself the following

 50:Do you really need a rich interactive user experience?

This is normally a requirement for consumer oriented applications, but for most business applications, you only need a “good” user experience, which AJAX is sufficient to provide.

Can you add Silverlight islands to your existing ASP.NET application instead of mixing the contents?
This should work for most scenarios. For example, Windows Live Mail is built in ASP.NET, with a few Silverlight islands, such as a slideshow program that allows you to view photo attachments with enhanced experience (actually, most Microsoft created web applications take this approach).

Will this be a good chance to revise your architecture?
Most traditional ASP.NET applications use the B/S or three tire architecture in which the application works with a database either directly or through a business logic layer. When porting applications to other platforms, these architectures will introduce many problems. When investigating Silverlight, it is also a good chance to adopt SOA. Add a service facade layer on top of the business logic layer, and you can work with the services from almost any client, such as an ASP.NET application and a Silverlight application.

If you are already on SOA, it should be trivial to port to Silverlight, since you only need to rewrite a client application. With SOA, the ASP.NET AJAX approach and the Silverlight island approach will also be much easier to implement. If none of the above approaches is suitable, you may have to mix Silverlight content with ASP.NET. When using this approach, keep in mind that Silverlight can’t call ASP.NET server-side event handlers, and each post back (either partial or complete) will cause the

Silverlight application to reload.

51. What are the new features of Silverlight 4?


  • Support for Google's Chrome browser.
  • Web cam and microphone support.
  • Printing support.
  • Full keyboard access while running in full-screen mode.
  • Programmatic access to a user's local document folder.
  • Improved mouse support, including right button support and mouse wheel support.
  • Elevated trust and support for local Component Object Model (COM) objects.
  • New notification support to display messages to end users.
  • New and enhanced controls such as a RichTextBox and an enhanced DataGrid control.
  • New support for implicit theming of controls.
  • New hosted browser support for rendering HTML inside Silverlight.
  • WCF data layer enhancements.
  • Localization enhancements with bi-directional text.
  • Support for Managed Extensibility Framework.
  • Enhanced data binding support.
  • Enhanced animation effects.
  • Clipboard and drag and drop support.
  • Deep Zoom performance enhancements.
  • WCF Rich Internet Application (RIA) Services.
  • Content protection for H.264, and support for playing offline DRM protected media.