Wednesday, February 2, 2011

Interview Questions

ASP.NET Questions

Part II

26. What is connection pooling and how do you make your application use it?Opening database connection is a time consuming operation.
Connection pooling increases the performance of the applications by reusing the active database connections instead of create new connection for every request.
Connection pooling Behaviour is controlled by the connection string parameters.
Follwing the the 4 parameters that control most of the connection pooling behaviour.
1. Connect Timeout
2. Max Pool Size
3. Min Pool Size
4. Pooling

27. What is Viewstate?A server control’s view state is the accumulation of all its property values. In order to preserve these values across HTTP requests, ASP.NET server controls use this property, which is an instance of the StateBag class, to store the property values.

28. Can any object be stored in a Viewstate?An object that either is serializable or has a TypeConverter defined for it can be persisted in ViewState

29. What should you do to store an object in a Viewstate?Do serialization of convert the object to string

30. Explain how Viewstate is being formed and how it’s stored on client.
The type of ViewState is System.Web.UI.StateBag, which is a dictionary that stores name/value pairs. ViewState is persisted to a string variable by the ASP.NET page framework and sent to the client and back as a hidden variable. Upon postback, the page framework parses the input string from the hidden variable and populates the ViewState property of each control. If a control uses ViewState for property data instead of a private field, that property automatically will be persisted across round trips to the client. (If a property is not persisted in ViewState, it is good practice to return its default value on postback.)

31. What is the purpose of reserved word "using" in C#?
A keyword that specifies that types in a particular namespace can be referred to without requiring their full qualified type names.

32. Response.RedirectThe Response.Redirect method causes the browser to connect to a specified URL. When the Response.Redirect() method is called, it creates a response whose header contains a 302 (Object Moved) status code and the target URL. When the browser receives this response from the server, it uses this header information to generate another HTTP request to the new URL. When using the Response.Redirect method, the redirection happens at the client side and involves two round trips to the server: one to request the original page, which is met by the 302 response, and then a second to request the redirected page. 
 
33. The Server.Transfer method
It transfers page processing from one page directly to the next page without making a round trip without making a round trip to the browser. It provides a faster response with a little less overhead on the server.It does not update the client’s url history or current url.

34. What is Smart Navigation ?
Is the attribute of the page tag which allows the browser to sections of the form that have changed. The advantage of Smart Navigation is that the screen does not flash as it updated, instead, the scroll postion is maintained and the "last page" in the history is maintained. It is only availabe to the users with Microsoft Internet Explorer 5 or later.

35. 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 asHTML, Unload() - when page finishes loading.

36. What’s the difference between Response.Write() andResponse.Output.Write()?The latter one allows you to write formatted output.

37. What method do you use to explicitly kill a user’s session?The Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.

Syntax: Session.Abandon

38. How do you turn off cookies for one page in your site?Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the user’s hard disk when a session ends.

39. Which two properties are on every validation control?
ControlToValidate & ErrorMessage properties

40. How do you create a permanent cookie?
Setting the Expires property to MinValue means that the Cookie never expires.

41. Which method do you use to redirect the user to another page without performing a round trip to the client?
Server.transfer()

42. What does WSDL stand for?
Web Services Description Language

43. 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 DataMember property which Gets or sets the specific table in the DataSource to bind to the control and the DataBind method to bind data from a source to a server control. This method is commonly used after retrieving a data set through a database query.

44. What tags do you need to add within the asp:datagrid tags to bind columns manually?
Column tag and an ASP:databound tag.
45. Which control would you use if you needed to make sure the values in two different controls matched? Use the CompareValidator control to compare the values
of 2 different controls.

46. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?
Every Page object (which your .aspx page is) has nine events, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are: Page_Init, Page_Load, Page_PreRender.

47. How many classes can a single .NET DLL contain?
Unlimited.

48. What is datagrid?
The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data.

49. What’s the difference between the System.Web.UI.WebControls.DataGrid and and System.Windows.Forms.DataGrid?
The Web UI control does not inherently support master-detail data structures. As with other Web server controls, it does not support two-way data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.

50. How do you customize the column content inside the datagrid?
If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.

No comments:

Post a Comment