Friday, June 3, 2016

Jquery Interview Questions


What is a Jquery

  • Jquery is a fast,small and rich javascript library which allows us to make Html document traversal and manipulation,event handling,animation and ajax.
  • It works across a cross browsers.
How to make sure that DOM is ready using Jquery
  • By using $(document).ready() function we can make sure that DOM is ready.
How javascript and jquery are different
  • Javascript is a scripting language which Jquery is a library built in the javascript language that helps us to use Javascript language.
Can we have multiple document.ready() function on the same page
  • Yes we can have any number of document.ready() function on the same page.
What is a Jquery selector
  • Jquery selector is a function which makes use of expression to find out the matching element from a DOM based on the given criteria.
  • We can simply say that jquery selectors are used to select one or more html elements using jquery.Once an element is selected then we can perform various operations on a selected element.
How to select elements using jquery with the given tag name
  • $('tagname') will select all the element of type tag name in the document.
  • For example $('p') selects all the paragraphs <p> in the document.
How to select single element using jquery with given element id
  • $('id1') will select the single element in the document that has an ID of 'id1'.
How to select elements using Jquery whose css class is cssclass1
  • $('.cssclass1') selects all the elements in the document that has a class of cssclass1.
How to select all elements using Jquery
  • $('*') selects all elements available in the document.
How to select multiple elements using Jquery
  • $('h1,div,span') will selects the specified selectors using jquery.
How to get attributes of an element using Jquery
  • The attr() method can be used to fetch the value of  an attribute from the first element in the matched set.
  • Example:$("img").attr("width","500");
How to remove an attribute from each of matched elements using Jquery
  • The removeAttr(name) can be used to remove an attribute from each of matched elements.
What is difference between .each() and $.each()
  • .each() is used to iterate over only jquery object collections where as $.each() allows us to iterate over javascript objects and arrays.
What is the fastest selectors in Jquery
  • ID and elements are fastest selectors in Jquery.
What is the slowest selectors in jquery
  • CSS selectors are the slowest selectors in jquery.
What is Jquery.noConflict
  • We have other client side libraries like MooTool,Prototype can be used with jquery and they also use $() as their global function and to define variables.Hence it creates a conflict as $() is used by Jquery and other libraries as a global function.To overcome this we make use of jquery.noConflict()
What is difference between body onload() and document.ready function
  • We can have more than one document.ready function in a page where as we can have only one body onload function.
  • document.ready function is called as soon as DOM is loaded where as body onload function is called when everything gets loaded on the page that includes DOM,images and all resources of  the page.
What is difference between Size and length of Jquery
  • Both size and length returns the number of elements in an object.But length is faster than size as length is a property and size is a method.
What is difference between attr and prop
  • jquery.attr() gets the value of an attribute for the first element in the set of matched elements.
  • jquery.prop() gets the value of a property for the first element in the set of matched elements.
When to use $(window).load instead of $(document).ready
  • In most cases script can be executed as soon as DOM is fully loaded so ready() function is the best place to write the javascript code.
  • But in some cases we need to make use of load() function to write script.For example to get the actual width and height of an image we make use of load() function.
  • As we know that load() function gets fired once DOM and all the css,images are fully loaded.So load() function is the best place to get width and height of an image.



Saturday, May 21, 2016

MVC


What is MVC
  • A MVC is an architectural pattern which separates the business logic and User interface.
  • It is broadly classified into three parts
  • Model:It is a business entity which is used to represent application data and provides the data to view.
  • View:It is responsible for look and feel and views are generated as per model properties.
  • Controller:It is responsible to take end user request,handles the user input data and loads an appropriate view and model.
What is difference between Html.Textbox and Html.Textboxfor in MVC
  • Html.Textbox is not a strongly typed and it does not requires a View.we can hardcore the values.
  • Html.Textboxfor is a strongly typed and it requires a View model.
What is Routing in MVC

  • Routing engine uses the Route table to match the incoming request URL pattern against the pattern defined in the Route table.
  • If any pattern matches with the route table then it forwards the request to the particular controller and the controller action method.
  • We can specify one or more url pattern to the route table with in the Register route method present in Application start event iii Global.asax file.
How can we restrict MVC actions to be invoked by Get or post methods
  • We can decorate the controller action method by "HttpGet" or "Httppost" attribute to restrict the type of Http calls.
What is difference between View data and View bag
  • Both are used to pass the data from controller to view but the difference between them is
  • Viewbag is a dynamic property where as viewdata is a  dictionary object.
  • Boxing and unboxing happens in View data where as it does not happens in Viewbag.
  • View bag performance will be high when compared to View data.
Does Tempdata preserves the data in Next request also
  • Tempdata is available for the current request and for the subsequent request it is available based on the whether the temp data value is read or not.
  • If the temp data value is read then it will not be available for the subsequent request.
What is Partial view in MVC
  • Partial view is similar to User control in ASP.Net.
  • Partial view is also called as a reusable view as it is rendered inside any other view.
  • Partial views can be reside in a shared folder or a specific view folder.
  • If we add a view to a shared folder then it is available for the entire application but if we add a view to a specific view folder then it is available for that view itself.
Difference between Partial and Render partial
  • Render partial returns void and the output will be written directly to the Response stream where as Partial returns "MVCHtmlString" which can be assigned to a variable and manipulate it when required.
  • If we want to change the output then we make use of Partial else Render partial.
  • Render partial performance will be fast as it writes the output directly to the Response stream.
What is the use of Peek and Keep in Tempdata

  • Tempdata will be persistant based on the Four conditions which are shown below
  • Not Read:If the Tempdata value is not read then the value of tempdata will be persistant for the Subsequent request.
  • Normal Read:If we read the value of the Tempdata then the Tempdata value will not be persistent for the subsequent request.
  • Read and Keep:If we read the Tempdata and if we call Keep method then the Tempdata will be persistent.
  • Peek and Read:If we read the Tempdata by using Peek method then the Tempdata value will be persistent for the Next request.
How can we enable Data Annotation validation on Client side
  • It is a Two step process to enable validation on Client side
  • First we need to set ClientValidationenabled and Unobstrusivejavascriptenabled to true in config file.
  • Second we need to add Javascript files which are listed below
  • jquery.1.7.1.min.js
  • jquery.Validate.min.js
  • jquery.Validate.unobstrusive.min.js
When to use ViewResult
  • If a controller action method make sure returns a View then we make use of View Result or else we make use of Sub types present in Action result.
What is difference between UpdateModel and Tryupdatemodel
  • UpdateModel will throws an exception if any validation fails but for Tryupdatemodel it will not throws an exception but it returns a Bool value indication whether validation gets Succeed or not.
Can we overload a MVC action methods
  • Yes we can overload two action methods with same name.If we run directly we will get an ambiguity error.In order to solve the problem we make use of ActionName attribute which will solve the problem.
What are Layout in MVC
  • Layout are very much similar to Master page in Asp.net whicl allows us to maintain a consistent look and behaviour for Multiple views.
How to enable and disable Optimization in MVC
  • To enable or disable optimization we need to write the below code in Application start event which is present in Global.asax file
  • system.web.optimization.BundleTable.EnableOptimizations=false;
Explain the Concept of Scaffolding
  • Scaffolding allows us to generate the CRUD(Create,Read,Update and delete) code and we can change the code as per our requirement.
  • Scaffolding uses Entity framework internally.
How to call one Actionmethod in a controller to another action method in the same controller
  • To call action method with in the same controller we make use of below code
  • return RedirectToAction("Action Name");
  • To call an action method which is present in another controller we make use of below code
  • return RedirectToAction("Action name","Controller Name");
What are Non Action methods in MVC
  • In MVC all methods which are present in controller are treated as Actions.So if we have a method in controller and if we don't want to use it as an action method then we need to decorate a method with "NonAction" attribute.
What is Viewstart page in MVC
  • In content pages or views we make use of Layout in many other views and if we want to use another Layout file we need to change the existing layout which we have used it in another views which is a Time consuming process
  • In order to overcome we make use of Viewstart file and will use layout property in  Viewstart file and refer this file in other views.So if we make any changes in Viewstart will automatically get reflected in all otheer views.
Can a view be shared across multiple controllers
  • Yes we can share a view across multiple controllers by placing the view in Shared folder.
In MVC which action filter executes first and which executes last
  • In MVC Authentication filter will executes first and the Exception filter executes last.
What is the difference between Asp.net wenforms and MVC

ASP.Net web forms
MVC
It consists of Web server controls to design UI. It consists of Html helpers to design UI.
It has state management techniques. It does not contains automatic state management techniques.
It has a file based Url means filename exists in the url.File name should be available in the web server where an application is hosted. It has a route based url means controller name and controller action method will be present in route table and will be invoked when end user sends an incoming request
It has a master page for consistent feel and look. It consists of Layout for consistent feel and look.
It has an user controls for re usability. It consists of partial views for Re usability..
No SOC(Separation of concern) as .aspx page is tightly coupled. It has SOC which separates views and controller


What are Hidden Input and Read only in MVC
  • Hidden Input:It is used when we don't want the end user to see or edit the property but ihe value of the property must be post to server when the form is submitted.Then we make use of Hidden Input attribute.
  • Read Only:It allows us to make the property read only but we can change the property value on the View.But when we post the form to web server model binder will treat the property as read only and will not change the value of the property.
How to change the Action name in MVC
  • "ActionName" attribute allows us to change the controller action name.
What is a Child Actionin MVC

  • An action method which is decorated with ChildActiononly is called as Child action.
  • These child methods does not respond to Url request.If we invoke a method using url  then it will get a compile error.
  • it can be rendered using @Html.Action("Method name");

Sunday, May 8, 2016

Snake Island


Snake island is one of the most deadliest place on the earth which is located in Brazil.This island is filled with 3000 to 4000 snakes live on 110 acre island and you can also find one snake for every six square yards.This island is mostly packed with golden lance head vipers which is one of the most deadliest snake in the entire world.

The snake venom is said to be three to five times stronger which can kill a person in under an hour and can melt human flesh.The Brazilian navy took action and closed the island to the public due to number of snakes and rapid increase in deaths who visits the island.

From 1909 to 1920s,a few people did live on the island in order to run its lighthouse.According to the tale the last lighthouse keeper,along with his family died when a group of snakes entered into his home through the windows.

The only people who are allowed on the island is the research team who receive waivers to collect data.There are only few scientists who have set foot on the snake island.

Stepping into the island requires the legal permission and a doctor need to be present at allowed time.If a person gets bit by a snake on the island an anti venom need to be injected to the person immediately.

Some claim that the snakes were put on the island by pirates to protect their treasure but in reality the population of snakes on the island evolved over 1000 years ago without human intervention.

Saturday, May 7, 2016

Ajax


What is an Ajax
  • Ajax stands for Asynchronous javascript and xml which is used for building better,faster and more interactive Web application.
  • It is also used to exchange the data with server and updating the parts of web page without refreshing the whole page.
  • It uses XMLHttpRequest object to interact with web server,
What are the triggers available in Update Panel
  • There are two types of triggers in Update panel.
  • Postback Trigger:It works with full postback means whole page will be processed
  • Asyncpostback trigger:In this only portions of web page will be processed instead of processing the whole page.
What are Synchronous and Asynchronous Requests
  • Both Synchronous and Asynchronous process the requests and gets the response back from the server.
  • In case of Asynchronous process it will send the request to server and it will not wait for server response.It will continue further process.
  • .But in case of Synchronous process client will send the request to server and will wait until the server sends the response back to client.
How to control the duration of an Ajax request
  • AsyncpostbackTimeout is the property of Scriptmanager to specify the duration for Ajax Request.
  • Default value is 90 Seconds.
    Example:<asp:scriptmanager runat="server" id="scmgr1" AsyncpostbackTimeout ="120"/>

What is an Update Panel in Ajax
  • Ajax Update Panel allows us to avoid the full postback of the page and allows only partial page postbacks.
  • Ajax Update Panel consists of two child tags ContentTemplate and Triggers.
  • ContentTemplate is used to hold the content of the page.It means if we design a page with some controls then those controls need to be wrapped(placed) inside a contentTemplate.
  • Triggers are used to refresh the whole page or the portions of the page based on the trigger we choose.
What are the difference between Ajax and the Javascript


Ajax
Javascript
Ajax sends the request to server and does not wait for the response Javascript sends a request to server and waits for the response from the server.
Ajax minimise the overload on the server Javascript increases the load on the server


How can you find out that an Ajax request ahs been completed
  • Readystate property is used to check whether Ajax request has been completed or not.If Readyproperty is eqyal to Four then the request has been completed.
How can we cancel the XMLHTTPRequest in Ajax
  • Abort() Method can be used to cancel the XMLHTTPRequest in Ajax,
What is a ScriptManager in Ajax
  • ScriptManager allows us to load Ajax related objects on the page.
  • It loads Ajax related scripts and libraries.
  • It provides an access to web services.
  • It also allows us to enable the feature of partial rendering of a web page.
What are different Readystates in XMLHTTPRequest
  • 0 - Ajax request not initialized
  • 1- Ajax request server connection established
  • 2-Ajax request received
  • 3- Ajax request Processing
  • 4- Request finished and response is ready
What is the use of XMLHTTPRequest in Ajax
  • The XmlHttpRequest object is the Key to Ajax.It is an API that can be used by Javascript,Jscript,VBScript and other web browser scripting languages to transfer and manipulate xml data using HTTP,establishing a connection channel between client side and server side.
  • Few of XmlHttpRequest methods are Abort,Open and Send.
  • Few of XmlHttpRequest  properties are Readystate,Status and onReadystatechange.
How to detect Asynchronous Partial page postbacks
  • IsInAsyncpostback is the property of scriptmanager to check whether it is Asynchronous postback or not.It returns a boolean value.
In which assembly Scriptmanager class is defined
  • It is defined in system.web.extensions.dll which is available in GAC.
What is the use of UpdateMode of an UpdatePanel
  • If we are working with Updatepanel then we make use of UpdateMode.
  • If Updatemode is set to Conditional then the content present inside the updatepanel will not get updated every time when any event is raised.
  • If updatemode is set to Always then the content present inside the updatepanel will get refreshed on every postback.It means if we set updatemode to Always then if any event occurs like Button click,dropdown selectedindexchanged events occurs then the content with in the updatepanel is refreshed.Therefore it causes the page performance as the content is refreshing every time.So we need to avoid and make use of Updatemode property to Conditional
What is Scriptmanagerproxy in Ajax
  • ScriptmanagerProxy enables nested components to add scripts and service references if a page already contains a scriptmanager control.
  • If a master page already had a one instance of Scriptmanager and we are referring the master page in content page(.aspx page) then we cannot make use of scriptmanager in content page.In such cases we make use of Scriptmanagerproxy which works same as a Scriptmanager.

Wednesday, April 27, 2016

Web Services


What is a Web Service
  • Web Services are used for developing an Interoperable applications and it make use of Open standard and protocols like xml,Http and SOAP.Since Web services make use of open and well known protocols an application built in any platform can communicate with web service.
  • For example an application built in JAVA Platform can communicate with web service developed using .Net platform and Vice versa.
What is a WebMethod attribute
  • Web Method:If we want to expose a method to the client as a part of Web service then we need to decorate a method with WebMethod attribute.
What is a WSDL
  • WSDL stands for Web service description language and it is used for describing Web service and it is written in XML format.
  • It contains the web service methods which are exposed to client.
  • It also contains the information about the method input parameters,input parameters data types and a Return type of a method.
What are WebMethod attributes properties in a Web Service
  • Description:To specify a description for a Web service we make use of Description property which is in WebMethod attribute.
  • MessageName:If we have two or more methods with same name but difference in Signature then we make use of MessageName property.
  • Cache Duration:If we want to cache the output of the Web service for a specific period of duration then we make use Cache Duration attribute.
  • EnableSession:If we want to make use of Session object in Web Service then we make use of EnableSession Property.
How can you make sure that only authorized users can access the web service
  • We make use of <authorization tag to make sure that only authorized users can access the web services.This tag allows or denies the access to web services based on their roles.
What is Webmethod overloading in Web service
  • WebMethod overloading means having the method with same name but difference in signature is Webmethod Overloading.
  • We make use of Messagename property of Webmethod attribute to channge the method names.
How can you prevent web service from unauthorized access
  • Web services can be prevented from unauthorized users by using
    1.Encryption and message based security
    2.Using authentication and accessing web services
What is SOAP
  • SOAP: Its full form is Simple object access protocol which allows us to communicate between applications developed in different platform via network.
What do you mean by Interoperability in Web service

  • Web service allows various application to communicate with each other and share the data among themselves.
  • For example an application developed in Java platform can communicate with web service which is developed in .Net platform and Vice versa which makes an application platform and technology independent is Interoperability.

Tuesday, April 26, 2016

Javascript


What is a Javascript
  • Javascript is a client side scripting language which is used for performing client side web development.
  • Javascript functions can be placed either in body tag or head yag.
  • In order to reuse Javascript validations in all pages we need to place javascript code in a js file and refer the js file in web pages.
How do we add a Javascript on a Web page
  • We can add a Javascript on web pages by two ways
  • If a javascript code is very small then we need to perform in a web pages.
  • If a javascript code is very large then we need to add it in a separate file and use the file reference in web pages.

    Example:<script type="Text/Javascript" src="js file path"/>
What is difference between "==" and "===" in javascript
  • "==" checks for Equality
  • "+++" checks for Equality as well as Type(data type).
How to access the Textbox value in Javascript
  • var name=document.getElementById("textboxid").value;
What are Javascript types

  • Number,String,Boolean,Function,Object,Null and Undefined are Javascript types.
What are Undeclared and Undefined Variables
  • Undeclared variables are one which does not exists in a program and if we tries to read the value of undeclared variables then we get a runtime error.
  • Undefined variables are those that are declared in a program but not been initialized a value.If a programmer tries to read a value of undefined variable then undefined value is returned.

How to create an Array in Javascript
  • var names=new Array("Vikas","venkat");
    var idata=names[0];
What is the use of ISNAN function in javascript
  • ISNAN: Full form of ISNAN is Isnot a Number.This function returns true if it is not a number else returns false. 
  • Example: ISNAN("Venkat");  It returns true
What does "5" +6+7 evaluates 
  • Since first digit "5" is a string then every thing will be Concatenated(Combined).
  • Output is 567.
What does 2+3+"4" evaluates
  • Since first two numbers are integer it will be added and concatenated with thrid digit as it is a string.
  • Output is 54.
How to create an elements dynamically using Javascript
  • var tdivid=document.getElementById("divid"); // first getting div id
    for(i=0;i<9;i++)
    {
    var input=document.createElement("input");  // creating input element
    input.type="text";                                            // creating attributes for input element
    input.name="name" + i;
    tdivid.appendChild(input);                            //Appending element to div
    tdivid.appendChild(document.createElement("br")); //creating element  for a new line
    }
What is difference between alert and confirmation box
  • alert displays only one OK button where as Confirmation box is used to display two buttons with OK and Cancel.It returns a boolean value true or false
Where should Script tag should be placed
  • Script tag should be placed in body tag as in some cases javascript code will not work if we place it in head tag.
  • Example: If we set Textbox background color it works in body tag but it will not work in head tag because at that time elements will not be loaded in browser DOM.
What is Push in Javascript
  • Push: This method adds a new item to the end of an array and it can also increase the length of any array.
What is Pop in Javascript
  • Pop: It removes the last element from the array,returns that element and it also returns the length of an array.
What is Unshift in Javascript
  • Unshift: It adds an new item to the beginning of an array.
What is Shift keyword in Javascript
  • Shift:It removes the first item from an array and returns the array.
What is Slice in Javascript
  • Slice:This method returns the selected items from an array.
   What is a Mutator Method
  • Mutator Methods: Some methods modifies an array elements where as some methods will not modify the array elements.Methods which modifies an array elements are called as Mutator elements.
  • Example:Push,Pop and Unshift are Mutator elements.
What is a Closure in Javascript
  • Closure is nothing but adding a function inside another function is a Closure.
  • A closure is a inner function which can access outer function variables and can also access the outer function parameters.
Difference between Window.Open() and window.showmodaldialog in javascript
  • Window.Showmodaldialog opens up a modal window(Child window) which cannot loose the focus until window is close and we cannot access the parent window until child window is closed.
  • Window.open opens a window just like a browser window and we can also access the parent window even child window is not closed.
Difference between Page.Registerclientscriptblock and Page.Registerstartupscript
  • Both are the methods of a ScriptManager.Both are used to insert a client script dynamically in a web page.

RegisterClientscriptblock
Registerstartupscript
This method adds the javascript to the web page after the "<form>" opening tag. This method adds the javascript to the web page after the "<form>" closing tag.
We cannot access the html elements as elements are not been initialised We can access the Html elements as all the elements are initialised.

What is a Prompt box

  • Prompt box is a box which allows the user to enter input by providing a textbox.
What is a "this" Keyword in a Javascript

  • "this" keyword is used to point to a current object in the code. (or) it refers to an object from where it is called
How can we submit a form using javascript
  • document.form[0].submit() is sued to submit the form
What is Variable typing in Javascript

  • Variable typing is used to assign a number to a variable and to the same variable it can be assigned to a string.
  • Example:Var i=10; i="venkat";
How to detect an Operating system on the client machine

  • navigator.appVersion is used to detect the operating system on client machine.
What is a Prototype in Javascript

  • Let us assume we have a function with name getname and we want to invoke a function.To do this we will create an object.Let say if we create 100 objects then there will be a 100 copies of getname function.
  • If we don't want to create the copies of the function and if we want all the object to share the one copy of getname function then we make use of Prototype which is nothing but a Prototype





Monday, April 25, 2016

ADO.Net


 What is Ado.Net in brief

  • ADO.Net stands for Activex Data object and it contains set of libraries which allows us to interact with database and XML.
  • It also contains number of classes which allows our application to communicate with data source.
What is difference between ADO.Net and Classic ADO

ADO.Net
Classic ADO
It is a Disconnected Architecture. It is a Connected Architecture
It is provided by Data set and Data Adapter It is provided by Record set
Even though if an Application is disconnected with the database.we can retrieve and access data. Application need to be connected to the database always while working on a data

What are two fundamental objects in ADO.Net
  • Data set and Data Reader are two fundamental objects in ADO.Net
What is Object Pooling
  • Object Pooling is used to store Pool(groups) of object with in the memory which can be reused later.
  • When a new object is required to create then instead of creating a new object,Object in the pool can be allocated there by minimizing the creation of new objects.
What are DataAdapter.Update and dataset.Acceptchanges Method
  • Dataset.Acceptchanges will only changes the rows present in dataset but DataAdapter.Update method will perform DML Operations like Isert,Update or Delete and also reflects the changes made in dataset to database.
What are the Namespaces used in ADO.net to connect to a database
  • Namespaces which are used to connect to database are listed below
  • System.data Namespace
  • System.data.SQLClient-Which is used to connect to SQL database
  • System.data,OleDB-Which helps us to connect to Access,Oracle or SQL database.
What is the role of Dataset object in ADO.Net
  • Dataset allows us to store the data retrieved from database by dataAdapter and make it available for all .Net Applications.
  • In order to fill the data into dataset,Fill method in the dataAdapter is used.
  • When Fill method is called DataAdapter will opens a connection to database,Executes the select command,retrieves the data and fills it into dataset and closes the connection automatically.
  • As connection to the database is closed any changes made in dataset will not send directly  to database.
  • In order to send the changes made in dataset to database an Update method of Dataadapter is called which will again opens the connection to database,Performs the DML Operations like Insert,Update and Delete which will reflect the database and immediately closes the connection.
  • As connection to the database is Opened when required and will immediately closes the Connection when not required.This Architecture is called as Disconnected Architecture.
What is DataReader object in ADO.Net
  • DataReader is used to store the data retrieved by the command object Execute Reader and make it available for all .Net Applications.
  • DataReader is a connected Architecture and data with in the datareader is a Read Only mode and with in the datareader we can navigate only in forward direction.
  • To Access one by one record from the datareader we make use of Read method which is in datareader object.
What is the use of Connection Object
  • Connection Object helps us to Communicate with datasource and an Application.
  • Depending upon the parameters specified in the Connection string ADO.Net connects to the specific database,Opens a connection to database.
  • When the connection to database is established,SQL Commands will gets executed and fetches the data from database.
What is the use of CommandBuilder Class
  • CommandBuilder is used to automatically update a database according to the changes made in dataset
  • Whenever a data inside a row changes then Command Builder object will automatically generates a SQL Statements and commit the changes made in dataset to database.
What is the use of SQLCommand object
  • SQLCommand object allow users to interact with database and performs an DML Operation like Insert,Update,Delete and Select for retrieving and manipulating data.
What are the components of ADO.Net provider
  • It mainly consists of Connection,Command,Data Reader and Dataadapter objects.
  • Connection Object: It allows us to connect to the database based on the parameters specified in the Connection string.
  • Command Object:  Once after the connectivity to the database is established then SQL Commands will get executed for retrieving and Manipulating data.
  • Data Reader: It allows us to retrieve data from database with the help of Execute Reader.
  • Data Adapter:It acts a a Mediator which allows us to communicate between database and an Application.It retrieves the data from database and stores the data in dataset and also reflects the changes made in dataset to database.
What is Execute Reader,Execute Nonquery and Execute Scalar in ADO.Net
  • Execute Nonquery: It executes a SQL Statements with in the database and returns the Number of rows affected.
  • Execute Scalar: It returns a First column single value from the entire result set.
  • Execute Reader:It returns a result set by using DataReader object.
What is Connection Pooling in ADO.Net
  • Connection Pooling helps us to group the database connection in a cache which can be reused later.Every time opening a new connection to database is a time consuming process.
  • Therefore Connection pooling helps us to reuse the already existing and active connection which increases the performance of an Application.
  • To enable or disable Connection pooling set pooling property to true or false in Connection string.
Explain ADO.Net Dataadapter in brief
  • DataAdapter acts as a mediator which helps us to communicate between datasource and an Application.
  • DataAdapter retrieves the data from database and stores it in dataset and also reflects the changes that are made in dataset to database.
  • DataAdapter make use of Fill method to fill the data in dataset and to reflect the changes made in dataset to database Update method of DataAdapter is used.
What is difference between DataReader and Dataset

Dataset
DataReader
It acts as a disconnected Architecture It acts as a connected Architecture
With in dataset we can navigate forward and backward With in DataReader we can navigate in Forward direction
We can make changes in dataset We cannot make changes in dataReader as it is a Read only Mode.
Dataset is slower when compared with dataReader because it contains Constraints,Relationships among the table DataReader is faster when compared with dataset.


Which property is used to check whether dataReader is opened or Closed
  • DataReader consists of Isclosed property which is used to check whether it is opened or closed.
  • It returns true if datareader is closed or else it returns false.
Is it possible to edit  data in Repeater control
  • No it is not possible to edit the data in Repeater control.
What is difference between Dataset.clone and Dataset.copy
  • Dataset.clone copies the structure of dataset including constraints,schemas and relations where as Dataset.copy copies both structure and data from the table.
Which keyword is used to accept variable number of parameters
  • Params keyword is used to accept variable number of parameters.
What are the classes that are available in System.Data namespace
  • Classes which are available in System.Data are listed below
  • Dataset,DataTable,,DataColumn,DataRow,DataRelation and constraint
What are the classes available in System.Data.Common Namespace
  • DataColumnMapping and DataRowMapping are the two classes available in System.Data.Common Namespace

Saturday, April 23, 2016

SQL Server


   What are different types of  SQL Commands
  • There are four types of SQL Commands listed below
  • Data Definition Language:These commands allows us to create and modify the structure of database objects.Examples of DDL are Create,Alter,Drop and Rename.
  • Data Manipulation Command:These commands allows us to store,modify,retrieve and delete the data in database.Examples of DML Commands are Select,Insert,Update and delete.
  • Transaction control language:These commands are used for managing changes affecting the data.Examples of TCL are Commit,Rollback and Savepoint.
  • Data control language:These commands are used for providing security to database objects.Examples of  DCL are Grant and Revoke.

  What is Database Transaction
  • A Transaction is a group of commands which changes the state of database.It make sure that all  of the commands get succeeded or none of them Succeeded. If any one of the command in the transaction gets failed then all the commands get failed and any data which was modified in the database is Roll backed.
   What is Normalization and its types
  • Normalization:It is the process of organising data in database means itis used for elimination data redundancy(duplication) from database.
  • There are different types of Normalization listed below
  1. First Normal Form:Elimination of duplicate columns from the same table(No repeating groups)
  1. Second Normal Form:It should meet the requirements of First Normal form.
    Need to remove columns from the table which creates duplicate,move the columns to a separate table and relate both the tables by Primary-Foreign key Relation.
  1. Third Normal Form:
    It should meet the requirements of First and Second Normal Form.
    Need to remove columns which are not dependant on Primary key.
   What is a Primary Key
  • .A Primary key is a field where we can uniquely identify a record.
  • It does not contains any NULL Values and a table can have only one Primary Key.

    Example:
    CREATE TABLE TBLPRIMARY
    (
    SNO  INT NOT NULL PRIMARY KEY,
    NAME NVARCHAR(250)
    )
   What is a Foreign Key
  • A Foreign key is a field which is used to establish a link between Two tables.
  • A foreign key in one table is mapped to Primary key in another table.

    Example:
    CREATE TABLE TBLPRIMARY
    (
    EMPID  INT,
    FOREIGN KEY(SNO) REFERENCE TBLPRIMARY(SNO)
    )
  What is a Composite Key
  • It is a Combination of two or more columns in a table where we can uniquely identify a record.
  • If we create a primary key on two or more columns then it is said to be a Composite Key.

    Example:
    CREATE TABLE TBLCOMPOSITE
    (
    EMPID    INT,
    EMPNAME   NVARCHAR(250),
    EMPLASTNAME    NVARCHAR(250),
    CONSTRAINT  CNS_PRIMARY PRIMARY KEY(EMPID,EMPNAME)
    )
   What is a unique Key
  • It is a combination of two or more fields where we can uniquely identify a record.
  • It accepts only one NULL Value and it cannot have any duplicate records.
     Define Join and Explain different types of Joins
  • Join:It allows us to join two or more tables based on the common field between them is Join.
  • Different types of Joins are listed below
      . Inner Join: It is used to display rows only if there is a matching condition between both
          the  tables is Inner Join.

        Outer Join:If is used to return all the rows from both the tables if the joining condition
         is  matched or not is Outer Join.

      Note:Outer join consists of three types

        Left Outer Join:It returns all the rows from the left table and matching rows from the
         Right table unmatched rows from the Right table will returns NULL.

        Right Outer Join:It returns all the rows from the Right table and matching rows from the 
        left table,Unmatched rows from the left table will returns NULL.

        Full outer join:It returns ll the rows from both the tables if the join condition is matched or 
        not  is Full Outer Join.

     What is a Cartesian Join in SQL Server
  • Cartesian Join:When each row in a first table is mapped with each row in a second table is called as Cartesian or Cross Join.
    What is a View and different types of View
  • View:A View is a virtual table which is created on the result set of an SQL Statement.
  • A View can contains Rows and columns just like a Real table.
  • Creation of View is shown below
    Example:
    CREATE VIEW VIEWNAME AS SELECT * FROM TABLENAME
  • There are two different types of Views
  1. User defined View   2.System defined Views
         System defined Views: These are predefined views which already exists in
         Master database.It consists three different views.

         Information Schema View:In a SQL  Server database it consists of 20 different views 
         which  are used to get the physical information of database like Tables,Columns and 
         Views..

         Catalog View:These views are used to display the database Self describing 
         information.These Views gives the total information of what are the database objects 
         that are  available in  database like Views,Tables.

         Dynamic Management View:These views gives  the information to the Administrator
         about  the current state of SQL server Machine.These values helps the administrator to 
         diagnose  the  problem and tune the server for Optimal performance.

        User defined Views:It mainly consists of two types
       .Simple View:If we create a view on Single table then it is called as Simple View.

        Complex View:If we crate a view on more than one table then it is said to be a Complex 
        View,

What is Grant and Revoke commands
  • Grant:It is a command which allows us to provide an access or privileges on database objects to the user.
  • Revoke:It is a command which removes user access rights to the database objects.
   What is a Stored procedure and Advantages
  • A Store Procedure can be defined as set of logical group of SQL statements which are grouped together to perform a specific task is a Store procedure.
  • A store procedure can take input,process them and sends back the output.
     Advantages: Stored procedures are precompiled and stores in database which makes database
     to execute faster.
    2.As many queries are included in Stored procedure Round trip to server to execute 
       multiple  queries is avoided.

What are Magic tables
  • Inserted and deleted are called as Magic tables which are used in Triggers and are automatically created and managed by the SQL server internally to hold a recently Inserted,Updated and deleted values during DML Operations on a table.
What is a Trigger and types
  • A Trigger gets executed automatically based on the action performed on the table like Insertion,deletion or Updation of the data.
  • Triggers are automatically invoked we cannot explicitly invoke the Trigger.
  • Triggers are classified into Two types
  • After Trigger:These Triggers gets executed after we perform an action on a table like Insertion,deletion or updation.
  • Instead of Trigger:If we want to perform an logic present inside the trigger instead of inserting data in the data then we make use of Instead of Trigger.
  • Triggers are not supported for Views.
  • After Triggers can be classified into Three types
  • After Insert Trigger:These triggers are automatically invoked after performing an Insert command on a table.
  • After delete Trigger:These triggers are automatically invoked after performing an delete command on a table.
  • After Update Trigger:These triggers are automatically invoked after we perform an Update command on a table.
  • Instead of Triggers can also be classified into three types
  • Instead of Insert:If we want to perform an logic present inside the trigger instead of inserting the data in the table then we make use of Instead of Insert Trigger.
  • Instead of delete:If we want to perform a logic present inside the trigger instead of deleting the data in the table then we make use of Instead of delete trigger.
  • Instead of update:If we want to perform a logic present inside the trigger instead of updating the data in the table then we make use of instead of update trigger.
      Example for Trigger:
  • CREATE TRIGGER TRIGGERNAME ON TABLENAME
    FOR INSERT
    AS
    BEGIN
           DECLARE @ID INT;       SELECT @ID=I.EMPID FROM INSERTED I;
           INSERT INTO TABLENAME1 VAKUES(@ID);
    END
   Difference between Delete and Truncate Commands
  • Delete:
  • It is a DML Command
  • We can specify filters in Where clause.
  • It deletes the specific data.
  • It fires an Triggers
  • Delete is slower when compare with truncate because it removes data on row by row basis and records an entry in Transaction logs.
  • If we perform delete operation then the Identity column will not reset as it affects the rows but not on the data pages.
  • Truncate:
  • It is a DDL Command.
  • We cannot make use of Where clause.
  • It deletes all the data which exists in the table.
  • It will not fire trigger.
  • If we perform truncate on Identity column then it gets reset as it affects on data pages but not on the rows.
What is difference between Clustered and Non clustered index

Clustered Index Non clustered Index
It is unique for a given table and we can have
only one clustered index on a table.
We can create as many as clustered index as possible
Clustered index isautomatically created when we create a Primary key if no clustered index exists on a table Non clustered index is automatically created when we create a unique key.
clustered iindex does not requires a separate storage for index than the tahle storage Non clustered index requires a separate storage for a index information than the table storage
Clustered index is faster when compare with non clustered index Non clustered index is slower because it refer back to table data as index information is stored separately with table data.

What is Union,Except and Intersect Commands
  • Union:
  • It is used to combine the result set of two or more select statements and gets the distinct values.
  • In both the select statements datatype should be compatible to each other and both the select statements should have same number of columns.
  • Except:
  • It is used to return rows from the first select statement but not from the second select statement.
  • Intersect:
  • It is used to return common records from both the table.
What is difference between primary key and  Unique key

Primary Key Unique Key
It does not allow NULL values It allows only one NULL Value
By default it adds a Clustered index when we create a primary key By default it adds a Non clustered index when we create a  Unique key
A Table can have only one primary key A Table can have more than one Unique key

What is difference between Having and Where clause

Where Clause Having Clause
It can be applied on Non Aggregate columns it can be applied on  Aggregate columns
It filters the data before grouping has been performed It filters the data after grouping has been performed.

What is difference between Local and Global temporary tables.
  • Temporary tables are very similar to permanent tables.Permanent tables are created in a specific database and exists until database exists where as temporary table is created in a TempDB and are automatically deleted when temporary tables are no longer in use.
  • There are two types of Temporary tables
  • A.Local Temporary table   B.Global Temporary table

Local Temporary Table Global Temporary Table
It is created with single # as prefix It is created with double ## as prefix
It is visible to connection which creates it and are automatically deleted when connection is closed These are visible to all the connections and is automatcally deleted when the last connection referring to the table is closed
If temporary table is created with in the stored procedure then table is automatically dropped once after the execution of Stored procedure is completed


What is an Index and its types

  • Indexes: Indexes are database object which are created on one or more columns.
  • Indexes can be created on columns upto 16(columns max)
  • It allows us to improve the performance of  data retrieval and fetches the records from the database quickly.
  • Different types of Indexes are Clustered and Non clustered index.
  • Clustered Index:
  • It determines the physical order of data in a table.
  • Clustered indexes are very similar to telephone directory as all the data is arranged in Alphabetical order.
  • Primary key constrain automatically creates a clustered index if no clustered index exists on a table.
  • Non Clustered index:
  • Non Clustered index is very similar to textbook as the index is stored at different location and table data is stored at different location.
  • Unique key constraint will automatically creates a Non clustered index and we can create as many as Non clustered indexes on a table.
What is a Subquery and different types of Subquery
  • A Subquery is a query within another query.The outer query is called as Main query and inner query is called as Sub query.
  • Subquery is always executed first and the result of sub query is passed to the main query.
  • Different types of query are  A.Correlated Subquery  B.Non Correlated Subquery
  • Correlated Subquery: It depends upon the Outer query and it does not executes by itself.
  • Non Correlated Subquery: Both outer and inner query are independent to each other.
What are local and Global variables
  • Local Variables:These variables are declared with in the store procedure or body of a batch and can assign a value either by SET or SELECT statements.
  • Local variables starts with single  as prefix and we creates it explicitly.
  • Global Variables:These are special type of variables which already exists in the database and server always maintain the value for these variables.
  • Global variables starts with prefix @@ and we cannot create it explicitly.
What are constraints and different types of Constraints
  • SQL Constraints are used to specify the rules for data in a table.
  • If there is any violation between the constraint  and the data then the action is aborted by the constraint.
  • There are Six different types of constraints listed below
  • Not NULL: It indicates that a column cannot store Null value.
  • Unique Constraint: It make sure that each row for a column must have a unique value.
  • Primary key:A Primary key is a field where we can uniquely identify a record. and it does not allows Null values.
  • Foreign Key: It is used to establish a link between two tables and foreign key in one table is mapped with the primary key in another table.
  • Check:It is used to check the value entered in a table against the condition specified for a column with in the table.If the condition is not matched then it aborts the actions.
  • Default:It allows us to specify a default value when value is not specified for a column.
What is User defined functions
  • User defined functions accepts the input parameters,performs the action and returns the result.
  • We cannot perform any DML Operations like Insert,Update and delete.
  • Different types of functions are
  • System defined functions:It consists of two types A.Scalar function  B.Aggregate Function
  • User defined functions:It also consists of two types A.Inline table valued function B. Multistatement table valued function.
What are  Aggregate and Scalar functions

  • Scalar Function:It operates on a Single value and returns a Single value.
  • Example:UPPER,LOWER,LTRIM and RTRIM
  • Aggregate Function:It operates on  a collection of values and returns a Single value.
  • Example:MAX,MIN,COUNT
What are User defined functions in SQL
  • Inline Tabled value function:It returns a table as a result of action performed on the function.
  • The value of a table must be derived from Select statement.
  • MultiStatement tabled value function: It returns a table variable as a result of action performed by the function.
  • In this Table variable must be explicitly declared and defined whose values can be deived from Multiple SQL Statements.
What is difference between Inner Join and Outer Join
  • Inner Join:It returns records from both the tables if the condition specified in the Where clause matches.
  • Left Outer Join:.If returns all the rows from the left table and matching records from the right table.Unmatched records will returns Null
  • Right Outer Join:.If returns all the rows from the Right table and matching records from the left table.Unmatched records will returns Null.
What is difference between Join and Union

Join Union
It returns the result set from two or more tables based on the logical relationship between two tables. It combines result of two or more Select statements into a Single result set
It can fetch the duplicate records if a table contains duplicate records. It does not fetch duplicate records.


What are TOP,RANK,DENSE RANK  and NTILE functions.
  • TOP: It is used to retrieve records from one or more tables and limit the Number of records based on a fixed value.
  • RANK: It returns RANK for each and every row in a Result set.Rank function skips the sequence if there is a tie.
  • DENSE RANK: It is also same as Rank but the difference is that Dense_Rank will not skips the Sequence if there is a tie.
  • NTILE: It is used to distribute the rows into specified number of groups.
What is COALESCE function in SQL Server
  • It returns the first Not Null value from the expression in the list.
What is difference between Union VS Union ALL

UNION
UNION ALL
UNION removes the duplicate from the select statement UNION ALL does not removes the duplicate rows from the select statement.
Performance is slow because it performs DISTINCT to remove duplicate rows. Performance is fast.


What are Left,Right,CharIndex and Substringfunctions
  • Left: It starts from the LEFT most character of the string and moves to RIGHT.
  • Right: It starts from RIGHT most character of the string and moves to LEFT.
  • Charindex: It accepts two Arguments.First arguement is the character we are searching for and second is the string.
  • Substring: It accepts three arguments.First parameter is the string,Second parameter is the starting position of the string and third parameter is the End position of the string.
What are Replicate,Space,Patindex and Stuff Function
  • Replicate: It is used to repeat a string with specified number of times.
  • Space: It returns a string with specified number of spaces.
  • PatIndex: It returns the location of pattern of a string.Search is not a case sensitive.
  • Stuff: It deletes the sequence of character from a source string and inserts another sequence of character to the sequence string.
Difference between Stored Procedure and Function

Stored Procedure
Function
It contains input and Output parameters It contains only input parameters.
We can perform DML Operations like Insert,Update and delete. We cannot perform any DML operations like Insert,Update and Delete
It supports an exception handling It cannot supports Exception handling
We can call functions with in the Stored procedures We cannot call Stored procedures with in the functions.


What are Pivot and Unpivot operator in SQL Server
  • Pivot: It is used to turn an unique values from one column into multiple columns thereby rotating a Table.Basically it is used to turn Rows into Columns.
  • UnPivot: It is used to turn columns into Rows is Unpivot
What is a SQL Profiler
  • SQL Profiler is a tool which helps us to capture the activities like execution of SQL Statements and we can save all the activities in a trace file which is useful for Tuning advisor.
  • When we select the trace file and run it with the help of tuning advisor then it will give us how much estimation improvement can be achieved and it also gives us the recommendation to create an indexes on a table.
Difference between Scope identity and @@Identity and Ideal_Current
  • To get the last generated identity columns we make use of Scope identity and @@Identity and Ideal_Current.
  • Scope_Identity: It returns the last generated identity value with in the same scope and a same session.
  • @@Identity: It returns the last generated identity value with in the same session and across any scope.
  • Ideal_Current: It returns the last generated identity value across any session and across any scope.
What is Merge in SQL Server
  • Merge:It allows us to perform Insert,Update and delete in a single statement instead of performing with multiple statements.
  • It requires two tables
  • Source Table: It contains the changes that need to be applied to the Target table.
  • Target Table: The table that requires changes
How many system databases are available in SQL Server
  • There are four types of System databases which are listed below
  • Master Database: It is a System database which contains the information of Server's Configuration.
  • MSDB: It is used by SQL Server agents for Scheduling Jobs and Alerts.
  • TempDB: It stores the temporary database objects like Temporary tables.
  • Model DB: It is a Template database which is used in the creation of New database.

What is difference between Temp table and Table Variable

Temp Table
Table Variable
Temp Table is available in Temp Database It is available with in the memory
We can perform DDL Operations We cannot perform any DDL operations
We can create multiple tables with same name with in the Stored procedure We cannot create Multiple tables with same name
We cannot use it with in the function We can use it with in the function
We can create indexes on a Temp table We cannot create indexes on a table Variable


What is Integrated security in Connection string
  • If integrated security="false" then we need to provide User name and Password in the Connection string.
    Example:Data Source=localhost;user id=username;password=pwd;integrated security="false"
  • If integrated security="true" then current window credentials are used for Authentication.
  • No need to provide Username and Password in the Connection string.
What are different isolation levels in SQL Server
  • Read Uncommitted:It allows us to read the data that has been currently being modified in another transaction.But it has not yet committed the data.
  • Example:Let say we have to transactions T1 and T1.Transaction T1 has updated the data but not yet committed the data.Where as transaction T2 will not wait for transaction T1 to complete but transaction T2 will return the data.If transaction T1 fails and rollback the modified data then the data present in the Transaction T2 will not be available in database which is a dirty read.
  • Read Committed:It will return the committed data of a table.
  • Example:Let say we have two transactions T1 and T2.Let say Transaction T1 will perform update operation on a table then other transaction T2 will wait until transaction T1 gets completed and committed the data.

Monday, April 18, 2016

ASP.Net Interview Questions



     What is AutoPostback in ASP.Net
  • It is the Property of the control by which page will be posted back to server based on the Web server controls like Button click event and Drop-down selected index change event etc..
     How can we identify that Page is Posted or not
  • Page Object has "Ispostback" Property to check whether page is posted to server or not.
  • Ispostback returns a Boolean value.It returns "True" if page is posted to server else returns false.
   What is the Lifespan for Items stored in Viewstate
  • The data present in View state exists until the Current page is Active.
  • If Current page gets expired or any post-back happens to the same page then View state information will be lost.
  • If end user redirects to different page and comes back to the same page then also view state information will be lost.
    Why do we use APP_Code folder in ASP.Net
  • APP_Code folder contains Class files,Report files,data set files and all the items stored in this folder can be accessible through out the Application.
  • Only One APP_Code folder exists in the Application path.If folder contains two files with two different languages then we will get an Compile error as all the files present in this folder will  are build with one Assembly.
  • If we want to add two files with two different languages then we need to create two sub folders and we need to add files to it.
    What is Tracing and where it is used
  • Tracing helps us to view the information about the execution of  a specific page which is executed on the Web server.
  • Tracing can be enabled at Application level or Page level.
  • Enabling tracing at Application level can be done with in the Web.config file as listed below
                            <system.web>
                              <trace enabled="true"/>
                           </System.web> 
  • At page level add trace="True" attribute to the page directive. which is shown below
                      <%@ Page language="C#" Trace="true" %>
  • If tracing is enabled(means true) then all the messages are written in a trace.axd file and this file will be available to local users or remote users based on the configuration.
  • If localonly="true" then trace messages are available to local users not to Remote Users.
  • If localonly="False" then trace messages are available to Remote users not to local users.
System.web>
<trace enabled="true" localonly="true"/>
</System.web>
     Uses of Tracing:

  • If any Troubleshoot(Issues) happens then developers will debug the application at development phase and can solve the issues but at Production level it is not possible to debug the application to overcome this issue we make use of Tracing.
  What is Authentication and Authorization in ASP.net
  • Authentication:It is the Process of identifying the user based on the User credentials like User Name and Password.
  • Authorization:It is the Process of determining what rights and permissions that Authenticated user had.
  What is Globalization and Localization in ASP.Net
  • Let say we have an Application developed using English Culture and accessed the application.But some users want the Application to be developed using Hindi Culture or any other Culture.To overcome the problem we make use of Globalization and Localization.
  • Globalization:It is the process of designing and developing an Application in such a way that an Application need to support Multiple Cultures.
  • Localization:It is the Process of Customizing an Globalized Application as per our Current Culture.
  What is View state in ASP.Net
  • View State:It is a Client side State Management technique which is used to maintain the state of the page between Round trip to Server.
  • View state information exists until current page is Active.If Current page gets expired including the post back to same page then View state information will be lost.
  • We can configure the View state at Page level or at  Application level.
  • Application Level:If we enable view state at Application level then view state information will be available for entire Application.Enabling View state at Application level  should be done in web.config file is shown below
                                            <System.web>
                                       <pages enableviewstate="True"/>
                                           </System.web>
  • Page level:If we enable View state at page level then View state information will be available only to that particular page itself.Enabling view state at page level is shown below
               <%@ Page language="C#" enableviewstate="true"%>
  • Advantages:
  1. It is easy to implement.
  2. No server resources are required.
  3. It is secured as the View state information is Encoded.
   Which Method is used to force all the Validation controls to run
  • Page.Validate() Method is used to force all the Validation controls to run and perform validation.
    Difference between Page.Validate() and Page.Isvalid property
  • IsValid: IsValid is a Page property to check whether the page validation gets succeeded or not.
  • Validate:It is the property of the control which is fired automatically if the Web server controls like button,drop down and other server controls has causevalidation property set to true.
   Difference between Client side and Server side validation in Web page

Client Side
Server Side
It performs validation at client side with the help of javascript before page is submitted to Server. It performs validations at server side and one of the main advantage of server side validation is if javascript is disabled then client side validation will not work then we make use of server side validation


  Difference between Response.Write and Response.Output.Write methods.
  • Response.Write:It allows us to write the Normal output.
  • Response.Output.Write:It allows us to write formatted Output.     
  • Response.write(".Net{0}","ASP"); it will not work for Response.Write as it is formatted Output but it will work for Response.Output.Write.
  • Response.Write(".Net ASP");It will work for both Response.Write and Response.Output.Write.
   What are Event handlers  available in Global.asax file
  • Global.asax file is used to server Application and session level events and we can have only one Global.asax file in our Application.
  • Events available in Global.asax file are
  1. Application_Start: It is automatically fired when the first instance of HTTP Application class is created.
  2. Application_Error: If any unhandled exceptions occurs in the Application then this event gets fired.
  3. Application_End: It is fired when Last instance of HTTP Application  is destroyed.
  4. Session_Start: It is fired automatically when new user visits the Application.
  5. Session_End: When session state's Mode is set to Inproc then this event gets fired otherwise it will not get fired.We can also call this event explicitly by using session.Abandon.
What are validation controls in ASP.Net
  • Validation controls allows us to validate the user input data whether the information entered is valid or not.Validation controls are of 6 types which are listed below
  • Required Field Validator:It allows us to check whether the data entered for input control or not.If input control is empty then it will display an error message.
  • <asp:Requiredfieldvalidator id="rfv1" runat="Server" controlToValidate="txtid" ErrorMessage="Input control should not be blank"/>
  • ControlToValidate and ErrorMessage ate important properties.
  • CompareValidator:It allows us to compare the data entered in an input control against the value in a different control.
  • <asp:comparevalidator id="cmpval" runat="Server" controltocompare="Textbox1" controlToValidate="Textbox2" ErrorMessage="Should be same" operator="Equal"/>.
  • If both the textboxes are empty then Validation gets succeeded so we need to make use of RequiredfieldValidator.
  • RangeValidator:It allows us to check whether the control value is within the Range.
  • <asp:Rangevalidator id="Rngv" runat="Server" controlToValidate="Textbox1" Maximumvalue="50" MinimumValue="10" type="Integer" ErrorMessage="Should be with in the range"/>
  • Regular Expression Validator:It allows us to check the User input data based on the pattern specified using Regular Expression.
  • <asp:RegularExpressionValidator id="regv" runat="Server" ErrorMessage="Not valid" ValidationExpression="\b123\b"/>
  • CustomValidator:CustomValidator can be used on both  Client side and Server Side and we can perform Custom Validations on client side with the help of Javascript.
  • Validation Summary:It allows us to display the summary for all the validation error that occurs on a page.
   Which methods are used to Post from one page to another page in Asp.Net
  • Response.Redirect
  • server.Transfer
  • Hyperlink
  • Server.Execute
  • Link Button
     Above methods are used to Redirect from one page to Another page in Asp.Net

    What is a Cookie in ASP.Net
  • Cookies: Cookies allows us to store small amount of information like user name,Password etc  on client machine
  • Cookies allows us to send information from one page to another page.
  • Cookies are classified into two types
  1. Persistent Cookie:If we set an Expiry date then it is said to be Persistent cookie.
  2. Non Persistent Cookie:If we don't set an Expiry date then it is said to be Non Persistent cookie
  Example
                :Response.Cookies["Data"].value="Venkat";
                 Response.Cookies["Data"].Expires=DateTime.Now.AddSeconds(1);// Persistent cookie


    What is Impersonation in ASP.Net and how to configure it
  • Impersonation:It is the Process of executing code in context of  another user identity is Impersonation.
  • By default All the Asp.Net application code is executed using fixed Machine specific account
  • In order to execute the code using another identity we make use of Impersonation.
  • Configuring Impersonation in Web.config file is shown below  
                <System.Web>
               <identity Impersonate="true"/>
               </System.Web>

   What is difference between Application state and Session State
  • Application State:These Application state variables are available for all users and across all the sessions.
  • But Session state are available for all users and for a given session.
  • Session State Variables are cleared when Timeout Occurs but Application state Variables are cleared when worker process is Restarted.
  • Application state Variables are stored on Web server itself but for session it can store in ASP.Net state server or it can store in SOL Server or it can store on Web server with in  Worker process.  
    How can you ensure that no one has tampered View state with in the Web page
  • To make sure that no one has tampered the View state in a Web oage we need to set "EnableViewstateMac" to true in Page directive
          <$@ Page language="C#" enableviewstatemac="true" %>

   Explain Cookieless session and its Working
  • Bydefault Session uses cookie.When end user sends a request to server,it creates a session id and this session id is stored as a cookie on client machine.
  • The Session ID is then used by web server to identify if the Request is coming from same server or different server.
  • If user disables cookie then it will not work.In order to Overcome we make use of Cookie less sessions.
  •  Enabling cookie less in web config is shown below
                   <System.web>
                           <Sessionstate cookieless="true"/>
                   </System.web>

     What is a Round Trip
  • The trip of a web page from client to server and again back to client is known as Round Trip.
    Where is View State information stored
  • The View state information is stored in a HTML hidden field with name _Viewstate.
    What is difference between HTML and Web server controls
  • HTML controls are client side controls therefore all the validations for HTML controls can be performed at client side.
  • Web server controls are Server side controls therefore all the validations can be performed at the server side.
  • We can convert HTML controls into web server controls by adding runat="Server" attribute which is shown below
  <input type="Text" name="txtname" runat="server"/> 

   What is difference between Hyper link and Link button
  • Hyper link does not have any Click and Command events where as for Link button we have click and command events.
  • Hyper link navigates to URL when user clicks on it where as for Link button the page is posted to server before navigating to URL  
    What are different types of Authentication Techniques
  • Windows Authentication:In this Authentication ASP.net web pages uses Local window users and groups to Authenticate and Authorize the resources.(web pages etc).
  • Implementation:
  • First we need set Authentication mode to Windows in web.config file.
  • Then in Authorization tag we need to deny anonymous users.
  • Finally we need to enable Window authentication in IIS.
  • Form Authentication:It is a cookie based authentication where username and password are stored on a client machine.We can also provide our own credential verification by comparing user credentials against database or xml file etc.
  • Implementation:
  • First we need to set authentication mode to forms in Web.config.
  • Then in Authorization tag we need to deny anonymous users.
  • Passport Authentication:It depends upon on the centralized services provided by the Microsoft.It identifies a user with E-mail address and a password and a single password account can be used with different websites.

    Difference between Machine.config and Web.config


Machine.Config
Web.config
It is automatically installed created when we install Visual studio. It is automatically created when we create an ASP.net application/td>
Configurations present in Machine.config is available for all the applications running the machine. Configurations present in Web.config is available to that Application itself/td>
Only one Machine.config exists on a server. We can have Multiple web.config files in a Application/td>


Where does Machine.config resides

  • For 32 bit machine machine.config exists in below location
  • C:\Windows\Microsoft.NET\Framework\[Version]\config\machine.config
  • For 64 bit Machine.config exists in
  • C:\Windows\Microsoft.NET\Framework64\[Version]\config\machine.config

What is an Event bubbling

  • Basically we have a controls like Data grid,Repeater Controls,grid view can have a child controls inside them.
  • For example data grid control can have a child control like button control and this child control(button) does not raise their event by themselves instead it pass the event to parent control(data grid).As child control pass the event to parent is termed as Event bubbling.

    What is difference between Custom control and User control
  • Custom Controls are compiled into their own Assembly where as User control is compiled along with the Application.
  • Custom controls can be added to Tool box where as user controls cannot be added.
  • User controls are easy to create as it is similar to Web page where as Custom control is complex as there is no designer every thing has to be done in code.
  • A separate copy of user control is required in each application where as single copy of custom control can be used in Multiple projects.
   Difference between Response.Redirect and Server.Transfer
  • Response.Redirect involves round trip to server where as Server.Transfer conserves resources by avoiding round trip to Server.
  • Response.Redirect can be used for both  aspx and html pages where as  Server.Transfer can be used for aspx pages.
  • Response.Redirect  can be redirect to an external pages which is on another server where as Server.Transfer can be used to redirect to a page which is on same server but it cannot redirect to a page which is on different Server.
    Difference between Server.Transfer and Server.Execute
  • Server.Execute method redirects to a different page,execute the code and again come back to the initial page.
  • But Server.Transfer redirects to the different page but it will not come back to the Initial page
    What are Session State Modes in ASP.Net
  • There are Five types of Session state Modes in ASP.Net
  • Off: If we set the Session State Mode to Off then Session State is disabled for an Entire Application.We need to configure Session State mode in Web.config as shown below
           <System.web>
                <Sessionstate Mode="Off"/>
         </System.web>

  • In Proc: If the session state is set to Inproc then Session State Variables are stored on Web server Memory with in the Worker Process.Configuration for Session State mode is hsown below
         <System.web>
            <Sessionstate Mode="Inproc"/>
          </System.web>

  • State Server If we set the Session State Mode to State Server then all the Session Variables are stored in a process called ASP.Net State Server.
  • Steps to Implement ASP.Net Session State Server is shown below
        1. As ASP.Net State Server is a Window Service first we need to start the Window service.
        2. We need to configure the Mode as State Server in Web.config as  shown below

            <System.web>
          <Sessionstate mode="Stateserver" stateconnectionstring="tcpip=localhost:portnumber"/>
            </System.web>
  • SQL Server: If we set the Session State Mode to SQL Server then all the Session Variables are stored in the SQL Server database.
  • Custom:If we want to Save the Session Variables in another databases like ORACLE,DB2 etc then we make use of Custom Mode.
    Describe MAster Page in ASP.Net
  • Master Page allows us to create Consistent look and behavior for all the web pages in an Application.
  • Master pages acts as a fixed template for all other web pages and master page should contain at one Contentplaceholder where a web page will be merged with Master page at run time.
  • Extension for the Master page is .Master.
    Difference between Master page and User Control
  • Master page has a file extension of .Master where as for User control it has a file extension of .ascx
  • User control does not contains ContentPlaceholder where as for master page it contains Contentplaceholder
  • User control does not work like a fixed template.It can display in different manner in different situation.But Master page acts as a Fixed Template.
     What is Caching in ASP.Net
  • Caching allows us to store the entire Rendered HTML in the browser.Then for the subsequent request it will not process the whole web page again instead it will fetch the data from the browser which will improve performance.
 

  • From the above image it contains duration="5" means web page will be stored in the browser for 5 Seconds.Once after duration of 5 seconds is completed again  Web page will be processed once again and stores it in the Web browser.     
   Different Types of Caching in ASP.Net
  • There are 3 different tyoes of Caching as shown below
  1. Page Output Caching: In this Caching,the Entire Rendered HTML of a page will be cached with in the browser.When the sae page is requested again the Cached copy present in browser will be fetched,
     

    2. Fragment Caching: It allows us to cache the Portions(Parts) of page instead of caching
        whole page is Fragment Caching.In this Caching it will not cache the Web page instead it
        allows us to cache the User Control.
   


  • The above piece of code shown in the image above should be placed in User Control not in the Web page.        

      3. Data Caching: Data Caching allows us to fetch the data for a Complex query which will take
          a  lot of time from the data source and caches the data.Then for the Subsequent Request it
         will not  fetch the data from Data source instead it will serve(take) the Cached data.

    What is Cross Page posting in ASP.Net
  • Cross Page Posting allows us to post from one web page to another Web page.By default when we click on Button  then it will not post(goes) to another page it will be on same page.If we want to post to different page on Button click then we need to set Postbackurl property which is refereed as Cross page Posting.
   

     What is the use of Custom Error tag in Web.config file
  • If there is any Unhandled exception by default ASP.Net shows an default error page as shown below
  • In order to display an Custom error page we make use of  Custom Error.
  • We can display Custom Error at Page level or at Application level.
  • Setting Error Attribute at page level is shown below




  • Setting Error tag at Application level in web.config file is shown below
     

  What are different Custom Error Modes in ASP.Net
  • Different Modes available in Custom Error tag are
  1. On: If Custom Error Mode is set to "ON" then  Custom Error pages are displayed on both local and Remote Machines






  2. Off: If Custom error Mode is set to "Off" then Custom Error pages are not displayed.




  3. Remote Only: If Custom error mode is set to "Remote Only"then Custom error pages are displayed on Remote Machine and Error pages are displayed on Local Machine




   What is an  AutoEventWireup in ASP.Net
  • If AutoEvent Wireup is set to True the page event handler methods like page_Load,Page_init etc are automatically wired up with the Respective controls.
  • If we set to false then Page event handler methods are not fired automatically we need to call it Explicitly as shown below


  • .

 What is an Application Pool in IIS
  • Application Pool: It is used to separate the set of Worker process in IIS which shares the Same configuration.
  • Application pool are also used to separate Application for better performance and Reliability.
  • When Worker process or application is having any issue only that worker process gets affected without affecting another Worker process.
 What is Worker Process
  • Worker Process(W3WP.exe) runs the Application with in the IIS.
  • This Process is responsible for managing all the request and responsible which are coming from client system.
  • All the ASP.Net functionality runs under the scope of Worker Process.
What is Web Farming and Web Gardening
  • Web Farming: When we host an Application in Web server and multiple clients are requesting for resources then one web server is not sufficient as there might be huge amount of incoming traffic.Hence we need to host the Web Application in Multiple servers and divide the incoming traffic among them.This process is called Web Farming.
  • Web Gardening:When a Single Application pool contains multiple worker process then it is said to be Web Gardening
What is 3-Tier Architecture 
  • Presentation Layer: In this layer we design an User interface with the help of Web server or Html controls.End user will use this layer to enter the input data and this data is forwarded to Business logic Layer.
  • Business Logic Layer: It is the Middle layer which acts as a bridge between Presentation Layer and Data Access Layer.In this layer it performs an Business logic and validations as per business requirement.Once the validations or logic has been performed then it forwards the data to Data Access layer/
  • Data Access Layer: This layer communicates with database,Fetches the data from database and forwards the data to Business layer which in turn forwards the data to Presentation layer.
What is Instrumentation in ASP.Net
  • Instrumentation: It is nothing but the ability to monitor the execution of Application.Tracing and Debugging are subsets of Instrumentation.
  • Debugging is monitoring the execution of Application at Development phase.
  • Tracing is monitoring the execution of Application at Production level.

Will Website run without web.config
  • If our webpages does not make use of Keys present in Web.config file then our Web application will run.
  • If Application does not contains Web.config file then it will  read the configuration details from Machine.config file.
What is Response.Redirect True VS False
  • Basically Response.Redirect allows us to Redirect from one page to another page.
  • If Response.Redirect is "False" then the Current page is not terminated  but the code after the Response.Redirect will get executed and then it will redirect to different page.
  • But if we set to "True" then the current page will get terminated and the code written after the Response.Redirect will not get executed but it redirects to different page.
Difference between Session.Clear and Session.Abandon.
  • Session.Clear will clear all the session variable values where as Session.Abandon will kills(Terminates) the session.
What are page life cycle events in ASP.Net
  • When we send a request to server then it goes through series of page life cycle events as shown below
  • Page PreInit:First it checks for IsPostback property to determine whether it is the first time page is processed or not.
  • We can also creates an dynamic controls.
  • We can set theme property and master page dynamically.
  • Init Event:In this event each controls unique ID is set.
  • We can also read or initialize the control properties.
  • Init Complete:This event is raised once after the initialization of page and control is completed.
  • In this event page's state is not yet populated,we can access the server controls but it will not contains the information returned from the user.
  • PreLoad Event:In this event Viewstate information will be loaded to all the controls.
  • Page Load:This is the most commonly used event on Server side.All the code inside this event will execute once.
  • Control Events:This event is used to handle specific control events like Button click,Dropdown selectedindexchanged etc.
  • PreRender Event:This is the event where final changes to page or control is allowed.After this event we cannot change any control or Viewstate values.
  • Render Event:In this event It renders the HTML Page to the end user.
  • Unload Event:This event is used for clean up.Once after the page is rendered the objects get disposed.
What is ASP.Net Application life cycle
  • Application Life Cycle:When an end user sends a request to server an APPDomain is created by the Application manager where an Application runs and it creates a separation between two or more web applications.
  • With in APP Domain an instance of hosting environment is created which provides the information of av Application.
  • Then after Response objects are created like HTTPRequest,HTTPResponse and HTTPContext.
  • Finally an Application starts by creating the instance of HTTPApplication.
What is the order of execution of execution of Master page,User control and Content page
  • Initialization event(init event) will be raised from inner most control to outer most control like User control,Master page and Content page(Web page).
  • For remaining event like page load,pre Render and other events it will be raised from Outer most control to inner most control like Content page(Web page),Master page and User control.
Will website run without Web.config file
  • Yes it will run as it take the configuration settings from Machine.config file.
What is difference between Http and Https

HTTP
HTTPS
It is a hyper text transfer protocol which is responsible for sending and receiving information across network It is a secure http which is used for exchanging confidential information with server and it need to be secured in order to prevent from unauthorized access.
It is transmitted over network via port80 It uses port 443 instead of Http port 80

What is difference between Viewstate and Hidden field

View-State
Hidden-Field
View-State is a Variable Hidden-Field is a Server control
It can store large amount of data It stores small amount of data.
It is secure It is insecure

Can we store a datatable in cookie
  • Storing datatable in cookie is not a recommended one as cookie size is very small and in some cases cookie may be disabled by the browser.Hence it is not recommended to store datatable in cookie.
What are Http handlers and Http Modules in ASP.net
  • If we need to inject any pre processing logic before request hits the IIS then we need to make use of Http Handler and Http Module.
  • Http Handler:It allows us to inject the pre-processing logic based on the extension of file name requested.So when a page is requested,Http handle gets executed based on extension of file name and on base of verbs.
  • Http Module:It is a event based method which allows us to inject pre processing logic before resource is requested.when ever client sends a request for resource then request goes through events with in the pipeline.