Posts Tagged ‘asp tutorial’

ASP.Net Interview Questions

Saturday, October 11th, 2008

ASP.Net is a language or not? 
ASP.NET is not a language.It’s a frame work we can use to develop websites.

What is aspx? 
aspx is the extension used for Microsoft ASP.NET web pages.
ASP.NET is a framework that runs on the MS web server and allows for rich dynamic content. aspx files are compiled rather than interpreted, and run much faster than other scripted files.

What is the difference between ASP.NET &VB.NET?
Asp.net and vb.net both are in dot net family but asp.net is used to develop web site(web application) and vb.net is used to create a windows application.

What is the major difference between asp.net and c#.net? 
Asp.net is used to develop a web application by either using vb or c# based syntax. C#.net is used to develop a windows application.

What is the .net,why we use .net.what is the advantage to using .net other programming languages? 
.net is not a technology or language .it is an environment to develop an application either web/window/console based
It provide the ability to achieve versioning.
Remove legacy/dependancy over os end the com based componet.
Can acheieve side by side exceution.

How to publish my asp .net project on web site?
1.Rename to your home page as index.aspx

2.Open internet explorer and type the url ftp://xxxxx.xxx (your url).

3.You shoud enter the user name and password.

4.You can get some folders, in that open httpdocs, in this you have to paste the all pages.You can also paste the folders also but you should paste the all pages must directly but don’t paste in other folders.

What is Web.config file in ASP.NET? 
Web.config file, as it sounds like is a configuration file for the Asp .net web application.An Asp.net application has one web.config file which keeps configurations required for the corresponding application.Web.config file is written in XML with specific tags having specific meanings.We have Machine.config file also. As web.config file is used to configure one asp .net web application, same way Machine.config file is used to configure the application according to a particular machine. That is, configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring applications. 

What is the trace in ASP.NET? 
ASP.NET introduces new functionality that allows you to view diagnostic information about a single request for an ASP.NET page simply by enabling it for your page or application. Called tracing, this feature also allows you to write debug statements directly in your code without having to remove them from your application when it is deployed to production servers. You can write variables or structures in a page, assert whether a condition is met, or simply trace through the execution path of your page or application.  

What is Viewstate? 
View state is used by the ASP.NET page framework to automatically save the values of the page and of each control just prior to rendering to the page.When the page is posted, one of the first tasks performed by page processing is to restore view state. State management is the process by which you maintain state and page information over multiple requests for the same or different pages. 

Diffrence Between ServerSide and ClientSideCode ? 
server side code is responsible to execute and provide the executed code to the browser at the client side. The executed code may be either in XML or Plain HTML the executed code only have the values or the results that are executed on the server. The clients browser executes the HTML code and displays the result where as the client side code executes at client side and displays the result in its browser.The client side core consist of certain functions that are to be executed on server then it places request to the server and the server responses as the result in form of HTML.
 

Diffrence Between ServerSide and ClientSideCode ? 
Server side code is responsible to execute and provide the executed code to the browser at the client side. The executed code may be either in XML or Plain HTML the executed code only have the values or the results that are executed on the server. The clients browser executes the HTML code and displays the result where as the client side code executes at client side and displays the result in its browser.The client side core consist of certain functions that are to be executed on server then it places request to the server and the server responses as the result in form of HTML. 
 

Define three test cases you should go through in unit testing? 
1)Positive test cases (correct data, correct output).
2)Negative test cases (broken or missing data,proper handling).
3)Exception test cases (exceptions are thrown and caught properly).

What debugging tools come with the .NET SDK?
1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.
2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. 
 
Where are shared assemblies stored ? 
Global assembly cache.

What is a web services? 
Web services is a excellent way of performing remote method calls.
Its a platform independent one because it follows the xml standards.
We can find the available services in http://uddi.org/ is the place for universal description,discovery and integration of web services.

Why web services are used in asp.net?
It is a specification to achieve cross language,cross pltform and cross device integration (or)it can be considered as a class definition  where the definitions is maintained with in the web server as a service such that the definitions  can be accessed from any application developed using any language for any platform or device.

What is the transport protocol you use to call a Web service? 
SOAP is the preferred protocol.

How can you debug failed assembly binds? 
Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched.  

What is the purpose of .net frame work? 
Net Framework is an umbrella technology and has a lot of different technologies under it. For example, it
1. Introduces Asp.net for web development
2. Has languages to write Windows program, Windows services, Web Services.
3. Pre-coded solutions to common programming problems   called base class library. It includes user interface data accessdatabase connectivity cryptography web application development, numeric algorithms, and network communications
4. A runtime or virtual machine that manages the execution of programs written specifically for the framework,and a set of tools for configuring and building applications  like visual studio.

It also introduces language independence by introducing common language runtime. You can write code in any language.
The .NET Framework is a key Microsoft offering and is intended to be used by most new applications created for the Windows platform. 

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? 
Server.Transfer is used to post a form to another page. Response.Redirect is used to redirect the user to another page or site. 

Name two properties common in every validation control?
ControlToValidate property and Text property.

What is Satellite Assemblies?
Satellite assemblies are often used to deploy language-specific resources for an application. These language-specific assemblies work in side-by-side execution because the application has a separate product ID for each language and installs satellite assemblies in a language-specific subdirectory for each language. When uninstalling, the application removes only the satellite assemblies associated with a given language and .NET Framework version. No core .NET Framework files are removed unless the last language for that .NET Framework version is being removed. For example, English and Japanese editions of the .NET Framework version 1.1 share the same core files. The Japanese .NET Framework version 1.1 adds satellite assemblies with localized resources in a \\ja subdirectory. An application that supports the .NET Framework version 1.1, regardless of its language, always uses the same core runtime files. 

What data type does the RangeValidator control support?
Integer,String and Date.

What is Web.config file in ASP.NET? 
Web.config file, as it sounds like is a configuration file for the Asp .net web application. An Asp .net application has one web.config file which keeps configurations required for the corresponding application. Web.config file is written in XML with specific tags having specific meanings.We have Machine.config file also. As web.config file is used to configure one asp .net web application, same way Machine.config file is used to configure the application according to a particular machine. That is, configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring applications.

What do you mean Class?
Class is an organized store-home in object-oriented programming that gives coherent functional abilities to a group of related code. Its are definition of an object, made up of software code. Using classes, you may wrap data and behavior together (Encapsulation).you may define classes in terms of classes (Inheritance).We can also override the behavior of a class using an alternate behavior (Polymorphisms).

Difference between Abstract and Interface?  
1.We can’t create instances for both
2.Single inheritance in abstract class, multiple inheritance in interface
3.We can have concrete method in abstact class but not in the interface
4.Any class that needs to use abstract must extent
5.Any class that needs to use interface must implement
6.Interface all the variables are static and final.

What’s the difference between private and shared assembly?
Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

In your asp.net application there is a textbox, How can clear the textbox with out round trip?
Assume that your textbox ID is txt. And the button ID is btn. If you want to clear the text from textbox by clicking the button without refresh then do the following steps.

1) In Page_Load  write

btn.Attributes.Add(\”OnClick\”,\”clearIt();\”);

2) In javascript write the function

function clearIt()

{

document.getElementById(\’txt\’).value = \”\”;

}

Can we use http handlers to upload a file in asp.net? 
You can use HttpHandlers. But it is very limited. You can not get response back (status) if you use it. And it is very complex also. Generally we use Http Handlers to handle requests at Server Side like Putting common Authentication on Web services whole organization wide like this.

What is user control? 
User Control are the controls created by user. User Controls are created with the file .ascx extension. Suppose if same controls are to be repeated in several pages,we can create a user control and display it in all those pages. They have to be registered in the page with @Register directive.

Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler? 
Add an OnMouseOver attribute to the button.
Example: btnSubmit.Attributes.Add(”onmouseover”,”someClientCodeHere();”).

Whats an assembly? 
Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.

Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box? 
DataTextField property.

How to dynamically change connection string in web.config? 
In web.config
<appsetting>
<add key =\”constr\” value =\”Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=Database Name;Data Source=server Name\”/>
</appSettings>
in aspx page
string _constr;
_constr=ConfigurationManager.AppSettings[\"constr\"].ToString().

What is Flex-Grid in ASP.NET? 
In .net all data controls (GridView,Repeater,Datalist) are act like Flex grid.

What tags do you need to add within the asp:datagrid tags to bind columns manually?
Set AutoGenerateColumns Property to false on the datagrid tag.

What is the trace in ASP.NET? 
ASP.NET introduces new functionality that allows you to view diagnostic information about a single request for an ASP.NET page simply by enabling it for your page or application. Called tracing, this feature also allows you to write debug statements directly in your code without having to remove them from your application when it is deployed to production servers. You can write variables or structures in a page, assert whether a condition is met, or simply trace through the execution path of your page or application.  

What is delay signing? 
Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.

What is the use of AutoWireup in asp.net? 
AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.

What base class do all Web Forms inherit from? 
The Page class.

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? 
You must set the DataSource property and call the DataBind method.

How to give hyperlink to a file in “asp net”? 
Use <a href=\”file:///hello.txt\”>Open file</a>

What are Codes Refactoring? 
It feature of Visual Web Express.Codes Refactoring Codes Refactoring enables we to easily and systematical makes changes to your code. Code Refactoring is support everywhere that you can writes codes including both code-behind and single-file ASP.NET pages. automatically promote a public field to a full property.

What is ASP.Net Web Matrix? 
This is a free ASP.NET development environment from Microsoft. As well as a GUI development environment, download includes simple web server that can be used instead of IIS to host ASP.NET apps. This opens up ASP.NET development to users of Windows XP Home Edition, which cannot run IIS.

What’s a strong name ? 
A strong name includes the name of the assembly, version number, culture identity, and a public key token.

What’s a bubbled event? 
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

What are the different types of sessions in ASP.Net? Name them? 
1.In Proc mode: stores session state in a web server by default.
2.State server mode: stores session state in a separate process called asp.net state services. Ensure that session state is preserved when web application is restarted and make session state available to multiple webservers within a web farm.
3.Sql server mode: stores session state in sql server database. State is preserved when application is restarted and available to multiple webservers.
4.Custom mode: enables you to store a custom session storage provider.
5.OFF mode: disable session state.

Difference between session and cookie? 
Cookies will set the same value for the variable or string throught the whole application when ever it is being run.But session sets or stores the value only till the time period when the application is running once if the application is closed the session value also willl become null.

Explain what a diffgram is? and a good use for one? 
The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process? 
inetinfo.exe is the Microsoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe. 

How to make Virtual Directory? 
Click “Start > settings> control Panel > Administrative Tools > internet information services”.Expand Internet Information Server. Expand the server name. In the left pane, right-click Default Web Site, point to New, and then click Virtual Directory. . In the first screen of the New Virtual Directory Wizard, type an alias, or name, for the virtual directory (site name), and then click Next. . In the second screen, click Browse. Locate the content folder that you created to hold the Web content. Click Next. In the third screen, click to select Read and Run scripts (such as ASP). Make sure that the other check boxes are cleared. Click Finish to complete the wizard.

Which method do you invoke on the DataAdapter control to load your generated dataset with data? 
The .Fill() method

Where are shared assemblies stored ? 
Global assembly cache.

Can I dynamically set the Image URL for Image Control? A)No B)Yes 
YES Why Not.
Hint: Use eval

How are you Write to XML File ? 
XmlTextWriter textWriter=new XmlTextWriter(’filename.xml’);
 
//WriteStartDocument and WriteEndDocument methods open and close a document for writing textWriter.WriteStartDocument()
//write comment text Writer. Write Comment(’this is my first xml file.’) textWriter.WriteComment(’i'm lovin it’) textWriter.WriteStartElement(’studentDB’) //

write first elementtextWriter.WriteStartElement(’student’) textWriter.WriteStartElement(’name’,”);
textWriter.WriteString(’sourabh’);
textWriter.WriteEndElement();
textWriter.WriterEndElement();
textWriter.WriteEndDocument();
textWriter.Close();
}

Whats the significance of Request.MapPath( ) ?
Maps the virtual path in the requested URL to a physical path on the server for the current request.

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

How to connect asp.net with sql server ? 
It can be done through ADO.Net(Connected or Disconnected Architecture).

How long the value session variable has an effect when it not used by the program ? 
20 Minutes.

Where’s global assembly cache located on the system ? 
Usually C:\\winnt\\assembly or C:\\windows\\assembly.

Automatic Memory Management ? 
It’s entirely too easy for a small mistake to cause a program to chew up memory and crash, sometimes bringing the operating system to a screeching halt in the process. Programmers understand that they’re responsible for releasing any memory that they allocate, but they’re not very good at actually doing it. In addition, functions that allocate memory as a side effect abound in the Windows API and in the C runtime library. It’s nearly impossible for a programmer to know all of the rules. Even when the programmer follows the rules, a small memory leak in a support library can cause big problems if called enough. The .NET Framework solves the memory management problems by implementing a garbage collector that can keep track of allocated memory references and release the memory when it is no longer referenced. A large part of what makes this possible is the blazing speed of today’s processors. When you’re running a 2 GHz machine, it’s easy to spare a few cycles for memory management. Not that the garbage collector takes a huge number of cycles–it’s incredibly efficient. The garbage collector isn’t perfect and it doesn’t solve the problem of mis-managing other scarce resources (file handles, for example), but it relieves programmers from having to worry about a huge source of bugs that trips almost everybody up in other programming environments. On balance, automatic memory management is a huge win in almost every situation.

What is the base class of the .Net ? 
System.Object.

What technology is used to seperate the code from asp.net page ? 
Partial page class.

True or False: A Web service can only be written in .NET ? 
False

Which template must you provide, in order to display data in a Repeater control ? 
ItemTemplate.

Describe the difference between inline and code behind ?  
The main difference comes in that inline code is executed at a certain event level in the page lifecycle whether code-behind can be bounded to different levels of events (PreInit, Init, PreLoad, Load, DataBound, Unload, PreRender and so on)
Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

How can you tell the application to look for assemblies at the locations other than its own install ? 
Use the directive in the XML .config file for a given application.

Which control would you use if you needed to make sure the values in two different controls matched ? 
CompareValidator Control.

Define a transaction. What are acid properties of a transaction ? 
Transaction is a sequence of operation performed as single unit of work. The sequence in which the operation are performed have the importance.
ACID (Atomicity,Consistency,Isolation and Durability) properties of a transaction are as follows:
Atomicity : Either all the operation of the transaction must be completed successfully or none of the operation is done at all.
Consistency: Completion of transaction must have the data in a consistent state.
Isolation: Changes made current transaction must be isolated from any other transaction running simultaneously.
Durability : Once the transaction is complete, it;s changes must persist permanently in the system.

What is the Global.asax used for? 
The Global.asax (including the Global.asax.cs file) is used to implement application and session level events. It resides in the root directory of the application. The .asax file extension signals that it’s an application file rather than an ASP.NET file that uses aspx. The Global.asax file is the central point for ASP.NET applications. It provides numerous events to handle various application-wide tasks such as user authentication, application start up, and dealing with user sessions. You should be familiar with this optional file to build robust ASP.NET-based applications.

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? 
You must set the DataSource property and call the DataBind method.

Does ASP.NET supports Linux Environment? 
Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris,Mac OS X, Windows, and Unix. Sponsored by Novell, the Mono open source project has an active and enthusiasticcontributing community and is positioned to become the leading choice for development of Linux applications.

Name two properties common in every validation control? 
ControlToValidate property and Text property.

What is the importance of HTML in web applications? 
It is important.But now-a-days due to other languages its use is decreasing.Earlier it was highly used for all sites.

How to attach javascript code into asp.net code?
Inorder to use script in your asp.net page place the script under head tag of ur aspx source page like this:
<head>
<script type=\”text/javascript\”>

———————-

—————–(place the script components here)

————————

—————————
</script>
</head>
 
Call the script functions from any control events called \”onclick()\” or \”onclientclick()\”

How ASP .NET different from ASP? 
Difference between ASP and ASP.NET

ASP stands for Active Server Pages. ASP.NET is the next
generation of ASP. After the introduction of ASP.NET, old
ASP is called ‘Classic ASP’.

Classic ASP uses vb script for server side coding. Instead,
ASP.NET supports more languages including C#, VB.NET, J#
etc. VB.NET is very similar to vb script, so it should be
easy for old Visual Basic or ASP programmers to switch to
VB.NET and ASP.NET

VB Script is a simple scripting language, where as VB.NET
or C# are modern, very powerfull, object oriented
programming languages. Just for that reason, you will be
able to write much more robust and reliable programs in
ASP.NET compared to ASP.

In classic ASP, there was no server controls. You have to
write all html tags manually. ASP.NET offers a very rich
set of controls called Server Controls and Html Controls.
It is very easy to drag and drop any controls to a web
form. The VS.NET will automatically write the required HTML
tags automatically for you.

ASP is interpreted, ASP.NET is compiled.

What is difference between Webportal and website?
A Website is all the pages, images and files contained under a domain name - such as www.happy-online.co.uk
A Web Portal is a type of Website. A Web Portal acts as a gateway to the internet. (A typical dictionary definition of the word portal would be - a doorway or a grand entrance.)
Take the website www.yahoo.com, this is a website, all the pages under the domain www.yahoo.com combine to make the website. However, Yahoo is often referred to as a Web Portal, if you have a look at the Yahoo Website you can see why it has often been called a Portal. The Website acts as a doorway (Portal) to the Internet, from the website you can search the web, go shopping, take part in auctions, read your email etc.

Key differences in features of .NET 2.0 and 3.5? 
.NET 3.5 has more advanced feature than .NET 2.0.They are WCF, WPF, WCS,WF and LINQ

What is cache?
A temporary data storage location, or the process of storing data temporarily. A cache is typically used for quick data access.

How to connect to sql server using windows authentication in asp?
In <Connection string> of web config file:
Write:
\”server=servername;datasource=databaseName;IntegratedSecurity=true\”
Done

What is Remoting? 
Remoting i s communication between  computers which are connect to each other through lan.

What is the .net,why we use .net.what is the advantage to using .net other programming languages? 
.net is not a technology or language .It is an environment to develop an application either web/window/console based.
It provide the ability to achieve versioning.
Remove legacy/dependancy over os end the com based componet.
Can acheieve side by side exceution.

How can you tell the application to look for assemblies at the locations other than its own install? 
Use the directive in the XML .config file for a given application.

Should validation (did the user enter a real date) occur server-side or client-side? Why? 
Client-side. This reduces an additional request to the server to validate the users input.

What is benefit of using grid? 
Main advantage with the grid is we can write bubble events means if we want to place some controls like text box, dropdownlist.To capture those child control events we can write only one single method for column of the grid.

How can i get the next records in gridview by clicking on “next”button using asp.net with C#? 
Gridview.selectedindex=girdview.selectedindex+1.

How to pass values from one form to another form? 
We can send information from one form to another using Cookies,Session,POST and GET methods in the form.

You have a query that runs slowly, how would you make it better? 
By creating index for the table to run the query fast and better.

Where do you store the information about the user’s locale? 
System.Web.UI.Page.Culture.

How to select ,edit,delete data through the datagrid control? 
There is a property name called CommandName in the Data Grid row item. With you can differentiate the select wdit and delete.

What does WSDL stand for? 
Web Services Description Language.

What is global.asax? 
Event procegars as to be placed with in specal file called as glob al.asax.

How many config files are there in Asp.net? 
THERE IS ONLY ONE CONFIGURATION FILE i.e web.config file for an application.The web.config file mantains configuration settings of an application.It is written in xml.

How to get the individual control index inside an item template of a datagrid as my item template have more than one web controls? 
Suppose you have many controls in datagrid itemtemplate. If you want to find any of them you can simple follow following synatax
ControlType NameOfControl = e.Item.FindControl(\”ActualNameofControlInDataGrid \”) as ControlType.

Example:
Lets further explain it with example.
Suppose you have a checkbox named \”chkBoxMessage\” in your datagrid and you want to find it. You simply write following code.

CheckBox chkBoxMessage = e.Item.FindControl(\”chkBoxMessage\”) as CheckBox.

What does the term immutable mean? 
It means to create a view of data that is not modifiable and is temporary of data that is modifiable. Immutable means you can’t change the currrent data,but if you perform some operation on that data, a new copy is created. The operation doesn’t change the data itself. Like let’s say you have a string object having ‘hello’ value. Now if you say temp = temp + ‘new value’ new object is created, and values is saved in that. The temp object is immutable, can’t be changed. An object qualifies as being called immutable if its value cannot be modified once it has been created. For example, methods that appear to modify a String actually return a new String containing the modification. Developers are modifying strings all the time in their code. This may appear to the developer as mutable - but it is not. What actually happens is your string variable/object has been changed to reference a new string value containing the results of your new string value. For this very reason .NET has the System.Text.StringBuilder class. If you find it necessary to modify the actual contents of a string-like object heavily, such as in a for or foreach loop, use the System.Text.StringBuilder class. 

What is the differences between release and debug in asp.net?
Actually the diffrence between the debug and release mode is, in debug mode the advance version of the .exe file could not replaced while in release mode it is replaced to the new .exe.

How we implement Web farm and Web Garden concept in ASP.NET?At least give an example.
When an application is hosted by multiple processes on the same server it is said to be a web garden environment.Also if an application is hosted by multiple servers then it is said to be web farm environment.

Is it possible to make windows application in asp.net if not then what kind of software use or technique use for making windows application?
We can make windows application on Asp.Net with VB.Net or C#