NET questions
.Net architecture
2. Param Says:
December 23rd, 2006 at 7:52 am
Page Request >> Start >> Page Init >> Page Load >> Validation >> PostBack Event Handling >> Page Rendering >> Page
Unload
Page Request - When the page is requested ASP.Net determines whether the page is to be parsed and compiled or a cached
verion of the page is to be sent without running the page.
Start - Page propertied REQUEST and RESPONSE are SET, if the page is pastback request then the IsPostBack property is SET
and in addition to this UICulture property is also SET.
Page Initilization - In this the UniqueID of each property is SET. If the request was postback the data is not yet loaded from the
viewstate.
Page Load - If it was a postback request then the data gets loaded in the control from the ViewState and control property are set.
Validation - If any control validation present, they are performed and IsValid property is SET for each control.
PostBack Event Handling - If it was a postback request then any event handlers are called.
Page Rendering - Before this the viewstate is saved from the page and RENDER method of each page is called.
Page Unload - Page is fully rendered and sent to the client(Browser) and is discarded. Page property RESPONSE and
REQUEST are unloaded.
3. Param Says:
December 23rd, 2006 at 8:00 am
4. Param Says:
December 23rd, 2006 at 8:02 am
Abstract class connot be instantiated instead it has to be inherited. The methods in abstract class can be overridetn in the child
class.
5. Param Says:
December 23rd, 2006 at 8:05 am
The application level variable hold value at the application level and their instances are destroyed when the no more client access
that application, whereas session corresspond to a individual user accessing the application.
6. Param Says:
December 23rd, 2006 at 8:08 am
What is web application virtual directory
7. Param Says:
December 23rd, 2006 at 8:11 am
No, maintaning value in cokkie woont be possible. In that case you have to make use of other ways to maintain state of the data
on page.
Request.Browser.Cookies property.
8. Param Says:
December 23rd, 2006 at 8:28 am
Explain serialization?
What is the difference between overloading and overriding ? how can this be .NET?
Overriding - Method has the same signature as the parent class method.
Overloading - Method having diff parameters list or type or the return type may be different.
Inherits
12. Paramjyoth Chadha Says:
December 23rd, 2006 at 3:07 pm
Friend/Internal - Method, Properties in that class can be accessed by all the classes within that particular assembly.
Protected Friend/Protected Internal - Methods, Properties can be accessed by the child classes of that particular class in that
particular assembly.
Friend/Internal - Method, Properties in a class can be accessed by all the classes within that particular assembly.
Protected Friend/Protected Internal - Methods, Properties can be accessed by all the classes in that particular assembly and also
by the child classes of that particular class.
This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in
response to the client postback.
Example:
Consider two combo boxes
In one lets have a list of countries
In the other, the states.
Upon selection of the first, the subsequent one should be populated in accordance. So this requires postback property in combo
boxes to be true.
In general:
Server: Whether local or remote.
Checkout: http://www.connectionstrings.com to get enlightened with various connection string infos for several databases.
.net ARchitecture
from top
1)Listing all languages
2) Cls
3) CTS
4) BAse class
5) All application used for designing code
6) Clr
7) OS
The .NET Framework provides specialized classes for data storage and retrieval.
These classes provide support for stacks, queues, lists, and hash tables.
The connection string can be stored in the WEB.Config file under element
The connection string can be stored in the WEB.Config file under element appsettings
Inheritance
Abstraction
Polymorphism
Encapsulation
If its a interface inheritance and the inheritad class is not a abstact class or a interface class then all the methods in the supper
class needs to be implemented.
The method in abstract class are virtual and hence they can be overriden in the child class.
Interface inheritance -
1. The accessibility modifier in Interface is public by defalut.
2. All the methods defined in the interface class should be oveririden in the child class.
Class Inheritance -
1. There is not restriction on the acessibility modifier in a class.
2. Only the method that are defined virtual should be overriden.
Stage Events/Method
Page Initialization Page_Init
View State Loading LoadViewState
Postback data processin LoadPostData
Page Loading Page_Load
PostBack Change Notification RaisePostDataChangedEvent
PostBack Event Handling RaisePostBackEvent
Page Pre Rendering Phase Page_PreRender
View State Saving SaveViewState
Page Rendering Page_Render
Page Unloading Page_UnLoad
Encapsulation: hides detailed internal specification of an object, and publishes only its external interfaces. Thus, users of an
object only need to adhere to these interfaces. By encapsulation, the internal data and methods of an object can be changed
without changing the way of how to use the object.
Inheritance: A class that derives from another class - known as the base class - inherits the same methods and properties. This
promotes reuse and maintainability.
Abstraction: the describing of objects by defining their unique and relevant characteristics (properties). Whilst an object may have
100s of properties normally only those properties of importance to the situation are described. (eg life policies premiums are
normally important; whereas the time of day a policy was purchased is not usually of value).
Polymorphism: Allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same
parent class, each derived class will have its own behavior. (Overriding and hiding methods)
Apartment Threading (STA): This allows multiple threads to exist in a single application. In single threading apartment (STA), each
thread is isolated in it’s own apartment. The process may contain multiple threads (apartments) however when an object is
created in a thread (i.e. apartment) it stays within that
apartment. If any communication needs to occur between different threads (i.e. different apartments) then we must marshal the
first thread object to the second thread.
Free Threading: The most complex threading model. Unlike STA, threads are not confined to their own apartments. Multiple
treads can make calls to the same methods and same components at the same time.
Net architecture
The order starting from the bottom
Polymorphism
Encapsulation
Abstraction
Inheritance
Param said,
How many web.configs can an application have?
@Param, Each directory can have a web.config file. but, the settings like httpmodules, authentication can resides in root
directory’s web.config file.
______________________
Sasi.
sasi.karasi@gmail.com
In ASP.NET2.0 page life cycle events are fired by the following sequence.
1.PreInit, 2.Init, 3.InitComplete, 4.PreLoad, 5.Load, 6.Control events, 7.LoadComplete, 8.PreRender, 9. SaveStateComplete, 10.
Render, 11.Unload
———
Sivakumar
http://www.dotnetanalyst.com
There can be more than one Web.config file in an application depend on how many subdirectories in your application. i.e. one
eb.config for one subdir.
41) What diff b/w overloading and overriding? How can this be .net
Overriding : derived classes follow the same base class method signatures.
Overloading : Derived classes may have different method signature with different parameters.
42) About virtual function and then use
Virtual function is that which is get override by the derived class to implement polymorphism.
44)if I want to override a method 1 of class A and this class B then how do u declared
answer :
public virtual void method1(){ }………..In class A. public override void method1(){}…………..In class B.
Each and Every ASP.NET application has its own copy of configuration settings stored in a file called Web.config. If the web
application spans multiple folders, each sub folder has its own Web.config file that inherits or overrides the parent’s file settings.
while storing in web.config file it will minimize the code and performance willbe good compare to storing in code behind file
Q. What is the difference between overloading and overriding ? how can this be .NET
A.1.Overloading: Refers to two methods with same name but different Signature(varing parameters).
2.Overriding: Refers to inherit methods from base class with different same name as well as Signature.
Hi all, I just wanted to ask your advice on a few things if you don’t mind. I have a web page and the IsPostback appears to be
going back and forth between true and false every time the thing is loaded and I don’t know where I can look in the
documentation for an indication of what or why these things are behaving in this way considering the fact that I have spent hours
upon days trying to untangle all the bits and peaces of this from that and the other oh why won’t you help me please to help me to
figure out why my conundrum clouds my ever doglegged contraption of a mental auction house barstool.
Encapsulation
Polymorphism
Abstraction
1.Data Source = “./SQLEXPRESS”; serverName\instanceName as Data Source to use a specific SQL Server instance
Either
3.Uid=”UserID for SQL server” ;
4.Password= “Password for SQL server”;
OR
Integrated Security=”True”; Use Windows security
1. Runtime which is done by virtual functions, that is you have method overriding.
2. Compile time that is by the method overloading.
It is a way to make your class iterate like an array. i.e if you have have a class Car then you can access its object like mycar[0],
mycar[1] …
We can have multiple web.config in an application provided that are being in different directories(folders), each folder can have
only one web.config, and will affeted all the pages under the same folder, but typically a web application itself is divided into
multiple folders, so we can have multiple web.config, and if a particular folder does not have web.config, then the web .config
present in its parent folder will be applicable to the all pages inside this folder.
An application can have any number of web.config files but each file in a seperate folder.
if an application has 5 folders then the application can have 5 web.config files in the folders + 1 web.config file in root directory
ASP.NET OBJECTS?
Asp.NET life cycle? When request mode
Explain ADO and its objects.
What is side by side execution?
Explain serialization?
>> in c# using :
in Vb inhertans
If I want to override a method 1 of class A and this class B then how do you declared
>>class B : A
{
public override method1()
{}
}
>> friend == this type of members is available for all classs those are in same assembly
>> protected frined == same assembly classs and drive classs can able to access this type of members
multi_level == class A {}
class B : A {}
class c : B {}
A. You should have only one web.config. but in sub folder you can have one web.cofing to set configuration of that folders.
example if your application have 3 folders then 4 web.config have in your application
6.
1. State True or False: If you set AutoGenerateColumns=True and still provide custom column definitions, the DataGrid will render
both
o True
o False
2. The data from an XSL Transform with XmlReader can be returned in one of the following ways
o objReader = objXslT.Transform(objNav, nothing)
o objXslT.Transform(objNav, nothing)
o objReader = objXslT.Transform(objNav, nothing, objWriter)
o objXslT.Transform(objNav, nothing, objWriter)
3. Pick the command line that would result in the C# compiler generating an XML documentation file
o csc /doc:NewHome.xml NewHome.cs
o c /doc /docfile: NewHome.xml NewHome.cs
o csc /doc /out: NewHome.xml NewHome.cs
o csc /xml NewHome.cs
4. What is the comment syntax for C#’s XML-based documentation?
o /** and **/
o //#
o ///
o //*
1. Which of the following languages is NOT included in the default .NET Framework installation?
o C#
o VB.NET
o JScript.NET
o VBScript.NET
2. What are the different types of serialization supported in .NET Framework
o XmlSerializer
o SoapFormatter
o XPathNavigator
o HttpFormatter
3. The CLR uses which format for assembly version numbers
o Major:Minor:Revision:Build
o Major:Build:Minor:Revision
o Major:Revision:Minor:Build
o Major:Minor:Build:Revision
4. What tool is used to manage the GAC?
o GacMgr.exe
o GacSvr32.exe
o GacUtil.exe
o RegSvr.exe
tag be set to a value and if not how can you possibly pass data from a form page to a subsequent page?
58. How would ASP and ASP.NET apps run at the same time on the same server?
59. What are good ADO.NET object to replace to ADO Recordset object.
60. Explain the differences between Server-side code and Client-side code.
61. What type of code(server or client) is found in a Code-Behind class?
62. Should validation (did the user enter a real date) occur server-side or client-side? Why?
63. What does the “EnableViewState” property do? Why would I want it on or off?
64. What is the difference between Server.Transfer and response.Redirect? Why?
65. Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced.NET component?
66. Let’s say I have an existing application written using VB6 and this application utilizes Windows 2000 COM+ transaction services.
How would you approach migrating this application to.NET?
67. If I am developing an application that must accomodate multiple security levels though secure login and my ASP.NET web
application is spanned across three web-servers (using round-robin load balancing). What would be the best approach to
maintain login-in state for the users?
68. What are ASP.NET web forms? How is this technology different than what is available though ASP(1.0-3.0)?
69. How does VB.NET achieve polymorphism?
70. How does C# achieve polymorphism?
71. Can you explain what is Inheritance and an example in VB.NET and C# of when you might use it?
72. Describe difference between inline and code-behind?
73. What is loosely coupled solution in.NET?
74. What is diffgram?
75. Where would you use an iHTTPModule and what are the limitations of any approach you might take in implementing one?
76. What are the Advantages and DisAdvantages of viewstate?
77. Describe session handling in a webform, how does it work and what are the limitations?
78. How would you get ASP.NET running in Apache web servers? Explain it’s limitations.
79. What is MSIL and why should my developers need an appreciation of it if at all?
80. Which methos do you invoke on the DataAdapter control to load your generated dataset with data?
81. Can you edit data in Repeater control? How?
82. Which template must you provide, in order to display data in a Repeater control?
83. How can you provide an alternating color scheme in a Repeater control?
84. 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?
85. What base class do all web forms inherit from?
86. What method do you use to explicitly kill a user’s session? How?
87. How do you turn off cookies for one page in your site? Give an example.
88. Which two properties are on every validation control?
89. What tags do you need to add within the asp:datagrid tags to bind columns manually? Give an example.
90. How do you create a permanent cookie?
91. What tag do you use to add a hyperlink column to the dataGrid?
92. What is the standard you use to wrap up a call to a Web Service?
93. Which method do you use to redirect the user to another page without performing a round trip to the client? How?
94. What is the transport protocol you use to call a Seb Service SOAP?
95. What does WSDL stand for?
96. What property do you have to set to tell the grid which page to go to when using the Pager object?
97. Where on the Internet would you look for Web Services?
98. What tags do you need to add within the asp:datagrid tags to bind columns manually? How?
99. 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?
100. How is a property designated as read-only?
101. Which control would you use if you needed to make sure the values in two different controls matched?
1. ishaq Says:
October 26th, 2006 at 9:33 am
I want to know
what is multiple inheritance?
what is Virtual polymorphism?
how to fetch 5th and 15th record from the datagrid using c#.net?
2. vishal Says:
November 3rd, 2006 at 4:38 am
to fetch the records from any row just use the following technique:
datagrid.rows[n].columns[m]
where n is the row number and m is the column number
5. Ahmed Says:
January 26th, 2007 at 8:47 am
}
The static field can now be accessed by simply doing CashSales.GetMaxUnitsAllowed(). No need to create an instance of the
class.
Load assembly:
By using classes from the System.Reflection namespace.
Assembly x = Assembly.LoadFrom( “LoadMe.dll” );
Create assembly;
Use classes from System.CodeDom.Compiler;
12. If I have more than one version of one assembly, then how will I use old version (how/where to specify version number?) in
my application?
The version number is stored in the following format: …. The assembly manifest can then contain a reference to which version
number we want to use.
13. How do you create threading in.NET? What is the namespace for that?
System.Threading;
16. What is Asynchronous call and how it can be implemented using delegates?
A synchronous call will wait for a method to complete before program flow is resumed. With an asynchronous call the program
flow continues whilst the method executes.
//create object
SomeFunction objFunc = new SomeFunction();
//create delegate
SomeDelegate objDel = new SomeDelegate(objFunc.FunctionA);
17. How to create events for a control? What is custom events? How to create it?
An event is a mechanism used in a class that can be used to provide a notification when something interesting happens. (typical
evens in a windows application include: change text in textbox, double click or click a button, select an item in dropdown box).
A custom event is an event created by the user that other developers can use. For example assuming that we have a
CashTransaction class and we have a bank balance property in that class. We may want to set-up an event that provides a
notification when the bank balance drops below a certain amount. In order to produce an event the process would be roughly as
follows:
18. If you want to write your own dot net language, what steps you will you take care?
We will need to ensure that the high level code is compiled to MSIL (Microsoft intermediate language) so that it can be interpreted
by the CLR.
19. Describe the difference between inline and code behind - which is best in a loosely coupled solution?
The term ‘code behind’ refers to application code that is not embedded within the ASPX page and is separated out into a
separate file which is then referenced from the ASPX page. Inline code is the traditional ASP architectural model where business
logic code was embedded within the ASP page. Separating the business logic code from the presentation layer offers several
advantages:
1) It allows graphic designers and web developers to work on the presentation layer whilst the application developers concentrate
on the business logic.
2) The codebehind file is compiled as a single dll increasing the efficiency of the application,
3) The codebehind model offers a true OO development platform,
4) It speeds up development time as it allows developers to fully maximise the features of the .NET framework such as Cahing,
ViewState, Session, Smart Navigation etc.
5) Code is much easier to maintain and susceptible for change.
6) The compiler and VS.NET provides much better support for error checking, intellisense and debugging when using the code
behind model.
20. How dot net compiled code will become platform independent?
The raison d’etre for .NET was to cater for multiples languages on a single windows platform whereas the aim of Java was to
be a single language on multiple platforms. The only way that .NET can be platform independent is if there is a version of the
.NET framework installed on the target machine.
21. Without modifying source code if we compile again, will it be generated MSIL again?
No.
22. How does you handle this COM components developed in other programming languages in.NET?
use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use
System.Runtime.InteropServices
22. How does you handle this COM components developed in other programming languages in.NET?
use TlbImp.exe to import the COM types into your .NET project. If no type library for the COM component then use
System.Runtime.InteropServices
use RegAsm.exe to call a .NET developed component in a COM application.
23. How CCW (Com Callable Wrapper) and RCW (Runtime Callable Wrappers) works?
CCW: When a COM application calls a NET object the CLR creates the CCW as a proxy since the COM application is unable to
directly access the .NET object.
RCW: When a .NET application calls a COM object the CLR creates the RCW as a proxy since the .NET application is unable to
directly access the .COM object.
24. What are the new thee features of COM+ services, which are not there in COM (MTS)?
Role based security.
Neutral apartment threading.
New environment called context which defines the execution environment
25. What are the differences between COM architecture and.NET architecture?
.Net architecture has superseded the old COM architecture providing a flexible rapid application development environment which
can be used to create windows, web and console applications and web services. .NET provides a powerful development
environment that can be used to create objects in any .NET compliant language. .NET addresses the previous problems of dll hell
with COM by providing strongly named assemblies and side-by-side execution where two assemblies with the same name can
run on the same box.
28. Can you explain what inheritance is and an example of when you might use it?
Inheritance is a fundamental feature of any OO language. It allows us to inherit the members and attributes from a base class to a
new derived class. This leads to increased code reusability and also makes applications easier to develop, maintain and extend
as the new derived class can contain new features not available in the base class whilst at the same time preserving the
attributes inherited from the base class.
29. How can you write a class to restrict that only one object of this class can be created (Singleton class)?
Use the singleton design pattern.
public sealed class Singleton
{
static readonly Singleton Instance=new Singleton();
static Singleton()
{
}
Singleton()
{
}
31. What is close method? How it different from Finalize and Dispose?
finalise is the process that allows the garbage collector to clean up any unmanaged resources before it is destroyed.
The finalise method can not be called directly; it is automatically called by the CLR. In order to allow more control over the release
of unmanaged resources the .NET framework provides a dispose method which unlike finalise can be called directly by code.
Close method is same as dispose. It was added as a convenience.
6. Alex Says:
February 13th, 2007 at 3:45 pm
7. RajhaRajesuwari Says:
March 30th, 2007 at 1:56 am
What is a Delegate?
What is the purpose of autoeventwireup?
8. RajhaRajesuwari Says:
March 30th, 2007 at 2:02 am
9. Muthu Says:
June 12th, 2007 at 2:31 am
What is delegate?
Delegate encapsulates a reference to a method.
It has two types,
1.Simple delegate
At a time Only one method can be invoked by single call.
e.g: del delname=new delname(obj.function_name)//To assign a method
delname()//To call that method
2.multicast delegate
At a time two or more methods can be invoked by single call.
AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.
In the case where AutoEventWireup attribute is set to false (by default), event handlers are automatically required for Page_Load
or Page_Init.
However, when we set the value of the AutoEventWireup attribute to true, the ASP.NET runtime does not require events to specify
event handlers like Page_Load or Page_Init.
Panel vs GroupBox
Both panel control and Groupbox Control are the famous Container Controls.Panel and groupbox are almost same but they got
minute differences
1. Panel don’t allow you to enter text in it where as you can enter the text in the Group Box.(i.e U cannot set the caption in
the panel you can do it in the groupbox)
2.Panel has Horizontal and vertical Scroll Bar, Groupbox dont support this Horizontal and vertical Scroll Bars.
3.Group box control has a visible border around it where as panel does n’t have any visible border.
How does ASP.NET framework map client side events to server side?
10.
Reader Vinay Solanki faced these questions from Microsoft recruiter, who apparently was hiring straight out of college.
1. What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.
2. What is serialization, how it works in .NET?
3. What should one do to make class serializable?
4. What exactly is being serialized when you perform serialization?
A reader recently interviewed for C# position at Wipro and sent the following questions:
When a page request is sent to the Web server, whether through a submission or location change, the page is run through a
series of events during its creation and disposal. When we try to build ASP.NET pages and this execution cycle is not taken into
account, we can cause a lot of headaches for ourselves. However, when used and manipulated correctly, a page’s execution
cycle can be an effective and powerful tool. Many developers are realizing that understanding what happens and when it happens
is crucial to effectively writing ASP.NET pages or user controls. So let’s examine in detail the ten events of an ASP.NET page,
from creation to disposal. We will also see how to tap into these events to implant our own custom code.
I’ll set the stage with a simple submission form written in ASP.NET with C#. The page is loaded for the first time and has several
server-side Web controls on it. When the Web server receives a request for the page, it will process our Web controls and we will
eventually get rendered HTML. The first step in processing our page is object initialization.
1. Object Initialization
A page’s controls (and the page itself) are first initialized in their raw form. By declaring your objects within the constructor of your
C# code-behind file (see Figure 1), the page knows what types of objects and how many to create. Once you have declared your
objects within your constructor, you may then access them from any sub class, method, event, or property. However, if any of
your objects are controls specified within your ASPX file, at this point the controls have no attributes or properties. It is dangerous
to access them through code, as there is no guarantee of what order the control instances will be created (if they are created at
all). The initialization event can be overridden using the OnInit method.
After the Init event, controls can be referenced using their IDs only (no DOM is established yet for relative references). At
LoadViewState event, the initialized controls receive their first properties: viewstate information that was persisted back to the
server on the last submission. The page viewstate is managed by ASP.NET and is used to persist information over a page
roundtrip to the server. Viewstate information is saved as a string of name/value pairs and contains information such as control
text or value. The viewstate is held in the value property of a hidden control that is passed from page request to page request. As
you can see, this is a giant leap forward from the old ASP 3.0 techniques of maintaining state. This event can be overridden using
the LoadViewState method and is commonly used to customize the data received by the control at the time it is populated. Figure
2 shows an example of overriding and setting viewstate at the LoadViewState event.
Figure 2 - When LoadViewState is fired, controls are populated with the appropriate viewstate data.
During this phase of the page creation, form data that was posted to the server (termed postback data in ASP.NET) is processed
against each control that requires it. When a page submits a form, the framework will implement the IPostBackDataHandler
interface on each control that submitted data. The page then fires the LoadPostData event and parses through the page to find
each control that implements this interface and updates the control state with the correct postback data. ASP.NET updates the
correct control by matching the control’s unique ID with the name/value pair in the NameValueCollection. This is one reason that
ASP.NET requires unique IDs for each control on any given page. Extra steps are taken by the framework to ensure each ID is
unique in situations, such as several custom user controls existing on a single page. After the LoadPostData event triggers, the
RaisePostDataChanged event is free to execute (see below).
4. Object Load
Objects take true form during the Load event. All object are first arranged in the page DOM (called the Control Tree in ASP.NET)
and can be referenced easily through code or relative position (crawling the DOM). Objects are then free to retrieve the client-side
properties set in the HTML, such as width, value, or visibility. During Load, coded logic, such as arithmetic, setting control
properties programmatically, and using the StringBuilder to assemble a string for output, is also executed. This stage is where the
majority of work happens. The Load event can be overridden by calling OnLoad as shown in Figure 3.
After the server-side events fire on data that was changed due to postback updates, the object which caused the postback is
handled at the RaisePostBackEvent event. The offending object is usually a control that posted the page back to the server due
to a state change (with autopostback enabled) or a form submit button that was clicked. There is often code that will execute in
this event, as this is an ideal location to handle event-driven logic. The RaisePostBackEvent event fires last in the series of
postback events due to the accuracy of the data that is rendered to the browser.
Controls that are changed during postback should not be updated after the executing function is called due to the consistency
factor. That is, data that is changed by an anticipated event should always be reflected in the resulting page. The
RaisePostBackEvent can be trapped by catching RaisePostBackEvent, as in Figure 4.
Figure 4 - The RaisePostDataChanged and RaisePostBackEvent events are defined by the IPostBackDataHandler interface.
The point at which the objects are prerendered is the last time changes to the objects can be saved or persisted to viewstate. This
makes the PreRender step a good place to make final modifications, such as changing properties of controls or changing Control
Tree structure, without having to worry about ASP.NET making changes to objects based off of database calls or viewstate
updates. After the PreRender phase those changes to objects are locked in and can no longer be saved to the page viewstate.
The PreRender step can be overridden using OnPreRender
8. ViewState Saved
The viewstate is saved after all changes to the page objects have occurred. Object state data is persisted in the hidden object
and this is also where object state data is prepared to be rendered to HTML. At the SaveViewState event, values can be saved to
the ViewState object, but changes to page controls are not. You can override this step by using SaveViewState, as shown in
Figure 5.
Figure 5 - Values are set for controls in OnPreRender. During the SaveViewState event, values are set for the ViewState object.
9. Render To HTML
The Render event commences the building of the page by assembling the HTML for output to the browser. During the Render
event, the page calls on the objects to render themselves into HTML. The page then collects the HTML for delivery. When the
Render event is overridden, the developer can write custom HTML to the browser that nullifies all the HTML the page has created
thus far. The Render method takes an HtmlTextWriter object as a parameter and uses that to output HTML to be streamed to the
browser. Changes can still be made at this point, but they are reflected to the client only. The Render event can be overridden, as
shown in Figure 6 (below).
10. Disposal
After the page’s HTML is rendered, the objects are disposed of. During the Dispose event, you should destroy any objects or
references you have created in building the page. At this point, all processing has occurred and it is safe to dispose of any
remaining objects, including the Page object. You can override Dispose, as shown in Figure 6.
Figure 6 - The Render event will output custom HTML to the browser through the HtmlTextWriter object.
Conclusion
Each time we request an ASP.NET page, we run through the same process from initialization to disposal. By understanding the
inner workings of the ASP.NET page process, writing and debugging our code will be much easier and effective (not to mention
less frustrating).
Following are the questions from an interview I attended for in C#, ASP.NET, XML and Sql Server. I will try to add some
more as soon as I recollect. Hope these questions will be useful for people attending interviews in this area.
1. Observer Says:
March 17th, 2005 at 10:56 am
observer*
1:
It depends on what version of SQL Server. In 2K, it’s 8k. If you’re using nvarchars, it’s half that.
2:
Use the int keyword. I’m not sure what the question is asking: if you want to know what an int is defined as, it’s a 32-bit signed
integer, from -(2^31 - 1) to (2^31 - 1). Adding the unsigned keyword buys you one more bit.
3:
Many ways. A few: 1) create tiers, but the business logic in a different tier; 2) put it in a different assembly; 3) put it in SPs. There
are more, but the specific one you use should depend on your application. Each has pros and cons.
4:
Create a web control. If you’re using VS.NET, you’re only a few steps away from drag-and-drop into any ASP.NET page.
5:
VS.NET makes it easy, if you have it; just run in debug mode and you can step through your code. Otherwise, you’re doing a lot
of Response.Write statements or logging to a disk, or something of that sort.
6:
Assuming: 1) you’ve compiled in release mode, 2) you’ve satisfied all your other procedural requirements (those depend on the
group you’re working in) and, 3) there’s existing web space that’s set up correctly, copy the aspx files, then the dll files from the
bin directory into a bin directory. Don’t forget any ancillary files like web.config or other configuration files you may have referred
to in code. It’s really more complicated than that most of the time, but those are the general steps.
8:
It’s always best to assume that your target environment will one day be clustered. If it’s set up right, you should be able to use
application variables. It may not be, so it’s often wise to store them externally and write access wrappers. “Externally” could mean
in a DB or static files. If your application is big and hardcore, setting up a web service on a “cluster controller” to feed the cluster
machines isn’t a terrible idea, either.
9:
Web.config is the most important. Specific configuration determines which others might be important.
10:
XSLT transforms XML into XML. If you have an XML data file and you need to change the variable names (e.g. — if some part of
your data tier gives you XML, but in the wrong format), XSLT will give you the right XML listing. It can also be used to transform
XML data into XHTML for display to the user. Some browsers will do the XML-XHTML conversion automatically, but that’s a
dangerous assumption if you’re in a heterogenous environment.
I’m not going to answer #7. There are lots of differences from the ground up. For one, you can’t compare Java to .NET. You can
compare J2EE to .NET, or Java to C#. I don’t compare the languages; I just write in both. J2EE is a more defined environment,
but Microsoft covers a lot of the gaps with application software. There are entire books about this, and most of them get into the
religious questions.
3. Baki Says:
April 17th, 2005 at 4:11 am
Ans - Q.5: To debug precompiled components such as business objects and code-behind modules, you need to generate debug
symbols. To do this, compile the components with the debug flags by using either Visual Studio .NET or a command line compiler
such as Csc.exe (for Microsoft Visual C# .NET) or Vbc.exe (for Microsoft Visual Visual Basic .NET).
Using Visual Studio .NET1. Open the ASP.NET Web Application project in Visual Studio .NET.
2. Right-click the project in the Solution Explorer and click Properties.
3. In the Properties dialog box, click the Configuration Properties folder.
4. In the left pane, select Build.
5. Set Generate Debugging Information to true.
6. Close the Properties dialog box.
7. Right-click the project and click Build to compile the project and generate symbols (.pdb files).
5. vinodkumar Says:
July 1st, 2005 at 9:57 am
Declare a as int
6. Sameer Says:
July 22nd, 2005 at 5:07 am
Marvelous job.I m really impressed.I m quite sure that u update these Q/A’s time to time as techies like me depend upon these &
not only this, I cleared 5 interviews in various companies but they dont fix me up becoz i m fresher and they want experience.But i
will fight if your feed me with this type of help.
7. vipin Says:
July 25th, 2005 at 5:36 am
8. Karthik Says:
September 22nd, 2005 at 12:44 am
EMPNO SAL
———- ———-
7369 800
7499 1600
7521 1250
7566 2975
7654 1250
7698 2850
7782 2450
7788 3000
7839 5000
7844 1500
7876 1100
7900 950
7902 3000
7934 1300
14 rows selected.
ops$tkyte@8i>
ops$tkyte@8i> select empno, sal
2 from emp
3 where sal = ( select min(sal)
4 from ( select sal from emp order by sal desc )
5 where rownum
9. Karthik Says:
September 22nd, 2005 at 12:48 am
ops$tkyte@8i>
ops$tkyte@8i> select empno, sal
2 from emp
3 where sal = ( select min(sal)
4 from ( select sal from emp order by sal desc )
5 where rownum
I’m getting a problem while posting the solution for the following question, so please access the url directly for the solution
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:149212348066
You can use rank function to find highest position/salary. like rank() over order by salary. The best approach as far as i see . i
learnt this in my DB class at the U
Preethi
MSU,Mankato.
select min(salary)
from (
select top 5 salary
from employees
order by sal Desc
)
For example if we need to fing 5th Maximum salary,The SQL will be,
Select top 1 from ( Select top 5 from employee group by salary order by salary)
As if we have 10 employees of the same highest salary even then this query will exactly return the fifth highest salary, another
thing here 5 could be replaced by n to find any nth highest salary. Here top 1 or top 5 is postfixex with salary
Cheers
Both “In Try block” and “In Finally block” will be displayed. Whether the return is in the try block or after the try-finally block,
performance is not affected either way. The compiler treats it as if the return were outside the try block anyway. If it’s a return
without an expression (as it is above), the IL emitted is identical whether the return is inside or outside of the try. If the return has
an expression, there’s an extra store/load of the value of the expression (since it has to be computed within the try block).
21. I was trying to use an “out int” parameter in one of my functions. How should I declare the variable that I am passing to
it? - You should declare the variable as an int, but when you pass it in you must specify it as ‘out’, like the following: int i; foo(out
i); where foo is declared as follows: [return-type] foo(out int o) { }
22. How does one compare strings in C#? - In the past, you had to call .ToString() on the strings when using the == or != operators
to compare the strings’ values. That will still work, but the C# compiler now automatically compares the values instead of the
references when the == or != operators are used on string types. If you actually do want to compare references, it can be done as
follows: if ((object) str1 == (object) str2) { … } Here’s an example showing how string compares work:
23. using System;
24. public class StringTest
25. {
26. public static void Main(string[] args)
27. {
28. Object nullObj = null; Object realObj = new StringTest();
29. int i = 10;
30. Console.WriteLine("Null Object is [" + nullObj + "]\n"
31. + "Real Object is [" + realObj + "]\n"
32. + "i is [" + i + "]\n");
33. // Show string equality operators
34. string str1 = "foo";
35. string str2 = "bar";
36. string str3 = "bar";
37. Console.WriteLine("{0} == {1} ? {2}", str1, str2, str1 == str2 );
38. Console.WriteLine("{0} == {1} ? {2}", str2, str3, str2 == str3 );
39. }
40. }
Output:
Null Object is []
Real Object is [StringTest]
i is [10]
foo == bar ? False
bar == bar ? True
41. How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear
after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:
42. using System;
43. [assembly : MyAttributeClass] class X {}
Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.
or
[Obsolete("This is a message describing why this method is obsolete")] public int Foo() {...}
45. How do you implement thread synchronization (Object.Wait, Notify,and CriticalSection) in C#? - You want the lock
statement, which is the same as Monitor Enter/Exit:
46. lock(obj) { // code }
translates to
try {
CriticalSection.Enter(obj);
// code
}
finally
{
CriticalSection.Exit(obj);
}
47. How do you directly call a native function exported from a DLL? - Here’s a quick example of the DllImport attribute in action:
48. using System.Runtime.InteropServices; \
49. class C
50. {
51. [DllImport("user32.dll")]
52. public static extern int MessageBoxA(int h, string m, string c, int type);
53. public static int Main()
54. {
55. return MessageBoxA(0, "Hello World!", "Caption", 0);
56. }
57. }
This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method
C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that
the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the
Platform Invoke tutorial in the documentation.
58. How do I simulate optional parameters to COM calls? - You must use the Missing class and pass Missing.Value (in
System.Reflection) for any values that have optional parameters.
59. ……………
To Do: Comfirm these are correct answers. Many of these question I have obtained from other
sources and have found they are not entirely correct, or simply wrong.
5. What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
Remoting is a more efficient communication exchange when you can control both ends of the
application involved in the communication process. Web Services provide an open-protocol-
based exchange of informaion. Web Services are best when you need to communicate with an
external organization or another (non-.NET) technology.
15. Can you configure a .NET Remoting object via XML file?
Yes, via machine.config and application level .config file (or web.config in ASP.NET).
Application-level XML settings take precedence over machine.config.
16. How can you automatically generate interface for the remotable object in .NET with
Microsoft tools?
Use the Soapsuds tool.
…………….
1. What is the .NET Framework?
.NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine that turns intermediate language
(IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. An extensive class
library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development
(Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc.
2. Explain why tracing helps with exception handling.
Tracing allows you to record unusual events while your application is running, without users being aware of it. If an unanticipated exception
occurs, your application can write a message to the trace log, which helps you diagnose problems during testing and after deployment.
By searching directory paths. There are several factors, which can affect the path (such as the AppDomain host, and application
configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For
shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.
6. What are private assemblies and shared assemblies?
Location and visibility: A private assembly is normally used by a single application, and is stored in the application's directory, or
a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies
maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the
.NET framework classes.
Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies.
7. How can I produce an assembly?
The simplest way to produce an assembly is directly from a .NET compiler. You can then view the contents of the assembly by
running the "IL Disassembler" tool that comes with the .NET SDK.
Alternatively you can compile your source into modules, and then combine the modules into an assembly using the assembly
linker (al.exe). For the C# compiler, the /target: module switch is used to generate a module instead of an assembly.
8. What is managed code and managed data?
Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example
exception handling and security. For these services to work, the code must provide a minimum level of information to the
runtime. Such code is called managed code.
Managed data: This is data that is allocated and freed by the .NET runtime's garbage collector.
Managed code is code that is written to target the services of the common language runtime. In order to target these services, the
code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic .NET, and JScript .NET code is
managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by
specifying a command-line switch (/CLR).
Closely related to managed code is managed data—data that is allocated and de-allocated by the common language runtime's
garbage collector. C#, Visual Basic, and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged
through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch),
but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name
suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class
becomes a full participating member of the .NET Framework community, with the benefits and restrictions that brings. An
example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can
inherit from a Visual Basic class). An example of a restriction is that a managed class can only inherit from one base class.
9. How does assembly versioning work?
Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another
assembly) includes both the name and version of the referenced assembly.
The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally
viewed as incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as 'maybe
compatible'. If only the fourth part is different, the assemblies are deemed compatible. However, this is just the default guideline -
it is the version policy that decides to what extent these rules are enforced. The version policy can be specified via the application
configuration file.
Remember: versioning is only applied to shared assemblies, not private assemblies.
11. What operating systems does the .NET Framework run on?
The runtime supports Windows Server 2003, Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not
supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on XP and
Windows 2000/2003. Windows 98/ME cannot be used for development.
IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the
12. What is Namespace?
It gives you a way to organize your classes, so that related classes are bound together in a namespace.
It helps in large applications where different classes may be provided by different people, different teams, or even different
organizations. Avoiding name clashes in large applications can be quite a headache, and in the past, developers have resorted to
arcane naming conventions to ensure uniqueness for their class names.
Because Web applications run over the Internet, some exceptions occur outside the scope of the application. This means that
your application can't respond directly to these exceptions. These types of exceptions are identified by HTTP response codes,
which IIS can respond to by displaying custom error pages listed in your application's Web.config file.
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET
source code (of any language) is compiled to IL during development. The IL is then converted to machine code at the point where the
software is installed, or (more commonly) at run-time by a Just-In-Time (JIT) compiler. MSIL allows for true cross-language integration.
ASP.NET Web Matrix web server does run on XP Home. The .NET Compact Framework is a version of the .NET Framework for mobile
devices, running Windows CE or Windows Mobile.