Saturday, July 12, 2008

ASP.Net

Web farm: Multiple server

Web garden: single server

Asp.net and asp – differences?


Code Render Block Code Declaration Block
Compiled
Request/Response Event Driven
Object Oriented - Constructors/Destructors, Inheritance, overloading..
Exception Handling - Try, Catch, Finally
Down-level Support
Cultures
User Controls
In-built client side validation
Session - weren't transferable across servers It can span across servers, It can survive server crashes, can work with browsers that don't support cookies
built on top of the window & IIS, it was always a separate entity & its functionality was limited. its an integral part of OS under the .net framework. It shares many of the same objects that traditional applications would use, and all .net objects are available for asp.net's consumption.
Garbage Collection
Declare variable with datatype
In built graphics support
Cultures



1. Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process.

inetinfo.exe is theMicrosoft 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.

2. What’s the difference between Response.Write() andResponse.Output.Write()?

The latter one allows you to write formattedoutput.

3. What methods are fired during the page load?

Init() - when the pageis instantiated,
Load() - when the page is loaded into server memory,
PreRender() - the brief moment before the page is displayed to the user asHTML,
Unload() - when page finishes loading.

4. Where does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page

5. Where do you store the information about the user’s locale?

System.Web.UI.Page.Culture

6. What’s the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?

CodeBehind is relevant to Visual Studio.NET only.

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

8. Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler?

It’s the Attributesproperty, the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();")

9. What data type does the RangeValidator control support?

Integer,String and Date.

10. Explain the differences between Server-side and Client-side code?

Server-side code runs on the server. Client-side code runs in the clients’ browser.

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

Server-side code.

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

13. What does the "EnableViewState" property do? Why would I want it on or off?

It enables the viewstate on the page. It allows the page to save the users input on a form.

15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
• A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
• A DataSet is designed to work without any continuing connection to the original data source.
• Data in a DataSet is bulk-loaded, rather than being loaded on demand.
• There's no concept of cursor types in a DataSet.
• DataSets have no current record pointer You can use For Each loops to move through the data.
• You can store many edits in a DataSet, and write them to the original data source in a single operation.
• Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.

16. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines? This is where you can set the specific variables for the Application and Session objects.

17. If I’m developing an application that must accommodate 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?

Maintain the login state security through a database.

18. Can you explain what inheritance is and an example of when you might use it? When you want to inherit (use the functionality of) another class.

Base Class Employee. A Manager class could be derived from the Employee base class.

20. Describe the difference between inline and code behind.

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.

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

22. Whats MSIL, and why should my developers need an appreciation of it if at all?

MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.

23. Which method do you invoke on the DataAdapter control to load your generated dataset with data?

The .Fill() method

24. Can you edit data in the Repeater control?

No, it just reads the information from its data source

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

ItemTemplate

26. How can you provide an alternating color scheme in a Repeater control?

Use the AlternatingItemTemplate

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

28. What base class do all Web Forms inherit from?

The Page class.

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

31. What tag do you use to add a hyperlink column to the DataGrid?



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

SOAP is the preferred protocol.

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

False

35. Where on the Internet would you look for Web services?

(http://www.uddi.org)

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

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

CompareValidator Control

38. True or False: To test a Web service you must create a windows application or Web application to consume this service?

False, the webservice comes with a test page and it provides HTTP-GET method to test.

39. How many classes can a single .NET DLL contain? It can contain many classes.

How ASP and ASP.NET page works? Explain about asp.net page life cycle?


Order of events in an asp.net page? Control Execution Lifecycle?

Phase What a control needs to do Method or event to override
Initialize Initialize settings needed during the lifetime of the incoming Web request. Init event (OnInit method)
Load view state At the end of this phase, the ViewState property of a control is automatically populated as described in Maintaining State in a Control. A control can override the default implementation of the LoadViewState method to customize state restoration. LoadViewState method
Process postback data Process incoming form data and update properties accordingly. LoadPostData method (if IPostBackDataHandler is implemented)
Load Perform actions common to all requests, such as setting up a database query. At this point, server controls in the tree are created and initialized, the state is restored, and form controls reflect client-side data. Load event
(OnLoad method)
Send postback change notifications Raise change events in response to state changes between the current and previous postbacks. RaisePostDataChangedEvent method (if IPostBackDataHandler is implemented)
Handle postback events Handle the client-side event that caused the postback and raise appropriate events on the server. RaisePostBackEvent method(if IPostBackEventHandler is implemented)
Prerender Perform any updates before the output is rendered. Any changes made to the state of the control in the prerender phase can be saved, while changes made in the rendering phase are lost. PreRender event
(OnPreRender method)
Save state The ViewState property of a control is automatically persisted to a string object after this stage. This string object is sent to the client and back as a hidden variable. For improving efficiency, a control can override the SaveViewState method to modify the ViewState property. SaveViewState method
Render Generate output to be rendered to the client. Render method
Dispose Perform any final cleanup before the control is torn down. References to expensive resources such as database connections must be released in this phase. Dispose method
Unload Perform any final cleanup before the control is torn down. Control authors generally perform cleanup in Dispose and do not handle this event. UnLoad event (On UnLoad method)

Note To override an EventName event, override the OnEventName method (and call base. OnEventName).

How many objects are there in ASP.Net?

There are 6 objects.
1. Request
2. Response
3. Session
4. Server
5. Application
6. ObjectContext

session

What are server controls?

ASP.NET server controls are components that run on the server and encapsulate user-interface and other related functionality. They are used in ASP.NET pages and in ASP.NET code-behind classes.

What is the difference between Web User Control and Web Custom Control?

Custom Controls

Web custom controls are compiled components that run on the server and that encapsulate user-interface and other related functionality into reusable packages. They can include all the design-time features of standard ASP.NET server controls, including full support for Visual Studio design features such as the Properties window, the visual designer, and the Toolbox.

There are several ways that you can create Web custom controls:

• You can compile a control that combines the functionality of two or more existing controls. For example, if you need a control that encapsulates a button and a text box, you can create it by compiling the existing controls together.

• If an existing server control almost meets your requirements but lacks some required features, you can customize the control by deriving from it and overriding its properties, methods, and events.

• If none of the existing Web server controls (or their combinations) meet your requirements, you can create a custom control by deriving from one of the base control classes. These classes provide all the basic functionality of Web server controls, so you can focus on programming the features you need.
If none of the existing ASP.NET server controls meet the specific requirements of your applications, you can create either a Web user control or a Web custom control that encapsulates the functionality you need. The main difference between the two controls lies in ease of creation vs. ease of use at design time.
Web user controls are easy to make, but they can be less convenient to use in advanced scenarios. You develop Web user controls almost exactly the same way that you develop Web Forms pages. Like Web Forms, user controls can be created in the visual designer, they can be written with code separated from the HTML, and they can handle execution events. However, because Web user controls are compiled dynamically at run time they cannot be added to the Toolbox, and they are represented by a simple placeholder glyph when added to a page. This makes Web user controls harder to use if you are accustomed to full Visual Studio .NET design-time support, including the Properties window and Design view previews. Also, the only way to share the user control between applications is to put a separate copy in each application, which takes more maintenance if you make changes to the control.
Web custom controls are compiled code, which makes them easier to use but more difficult to create; Web custom controls must be authored in code. Once you have created the control, however, you can add it to the Toolbox and display it in a visual designer with full Properties window support and all the other design-time features of ASP.NET server controls. In addition, you can install a single copy of the Web custom control in the global assembly cache and share it between applications, which makes maintenance easier.



Web user controls Web custom controls
Easier to create Harder to create
Limited support for consumers who use a visual design tool Full visual design tool support for consumers
A separate copy of the control is required in each application Only a single copy of the control is required, in the global assembly cache
Cannot be added to the Toolbox in Visual Studio Can be added to the Toolbox in Visual Studio
Good for static layout Good for dynamic layout


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

ItemTemplate. To display data in the ItemTemplate, declare one or more Web server controls and set their data-binding expressions to evaluate to a field in the Repeater control's (that is, the container control's) DataSource.


Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_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.

What’s the difference between Response.Write() and Response.Output.Write()?

Response.Output.Write() allows you to write formatted output.

What methods are fired during the page load?

Init() - when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.

When during the page processing cycle is ViewState available?

After the Init() and before the Page_Load(), or OnLoad() for a control.

What namespace does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page

Where do you store the information about the user’s locale?

System.Web.UI.Page.Culture

What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

CodeBehind is relevant to Visual Studio.NET only.

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.

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();");

No comments: