Latest ASP.NET 2 Interview Questions
 
 

BACK

Q1. What is Dynamic Compilation?
A1. When an asp.net page is compiled for the first time, a copy of the compiled assembly is saved in the Temporary ASP.NET Files folder. This compiled page is of the type system.web.ui.page and includes all contents of the page (including html & scripts).
When it is compiled a second time, a precompiled version is accessed from this location, thus speeding up the process. In case the source is changed, the assembly in the Temporary ASP.NET Files folder gets deleted, and thus re-compilation occurs. This process is called Dynamic Compilation.

Compilation may be enabled or disabled at page level by setting the CompilationMode attribute in the Page Directive of the page.

Q2. How to set Dynamic Compilation for an entire website?
A2. In web.config, in pages element, add the attribute
CompilationMode="Auto".

Q3. Why do we sometimes need to disable compilation?
A3. In case of big sites with many pages, and we dont want to load an assembly into the memory for every page. We set CompilationMode="Never".
The pages are interpreted at runtime.

Q4. What is the FindControl method?
A4. A method that searches for a control, with a specific ID inside a container and get a reference to it. Its just like the
getElementById in javascript.

Q5. What is a partial class? Whats the advantage of using it?
A5. In ASP.NET 2.0, a class may be written at several places, and at the time of compilation, all these classes (having the same name) get compiled as one single class. Hence these classes are called Partial Classes.

Advantage, for example, Any change in Code-Behind page gets reflected in the Presentation Page(inline code) and vice versa, because of the partial class mechanism. Compare this with the older ASP.NET 1.1, whenever a change was made to Code Behind, change got reflected in Presentation page but the reverse threw an error. So for any change in the presentation page, like addition of a new control, we need to specifically add a reference of that control in the Code-Behind page. The concept of partial classes in ASP.NET 2 eliminates this problem.