Programming Index Cards

March 31, 2009

ASP.Net Interview Q’s

Filed under: ASP.Net — Tags: , — apcig @ 3:11 am

<!–[if !mso]> <! st1\:*{behavior:url(#ieooui) } –>

Taken from TechSvr Blog

Is it possible to debug JavaScript in .NET IDE? If yes, how?
Ans. Yes, simply write “debugger” statement at the point where the breakpoint needs to be set within the JavaScript code and also enable JavaScript debugging in the browser property settings.

How many ways can we maintain the state of a page?
Ans. 1. Client Side – Query string, hidden variables, ViewState, cookies
2. Server side – application, cache, context, session, database

What is the use of Singleton pattern?
Ans. A Singleton pattern is used to make sure that only one instance of a class exists.

What is an .ashx file?
Ans. It is a web handler file that produces output to be consumed by an xml consumer client (rather than a browser).

What is encapsulation?
Ans. Encapsulation is the process of hiding all of the details of an object that do not contribute to its essential characteristics.

What is a Delegate?
Ans. A delegate is a strongly typed function pointer object that encapsulates a reference to a method, and so the function that needs to be invoked may be called at runtime.

What is the base class of all web forms?
Ans. System.Web.UI.Page

How to add a client side event to a server control?
Ans. BtnSubmit.Attributes.Add(“onclick”,”javascript:fnSomeFunctionInJavascript()”);

How to register a client side script from code-behind?
Ans. Use the Page.RegisterClientScriptBlock method in the server side code to register the script that may be built using a StringBuilder.

Can we put a break statement in a finally block?
Ans. The finally block cannot have the break, continue, return and goto statements.

How to instruct the garbage collector to collect unreferenced data?
Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method.

What are Partial Classes in Asp.Net 2.0?
Ans. In .NET 2.0, a class definition may be split into multiple physical files but partial classes do not make any difference to the compiler as during compile time, the compiler groups all the partial classes and treats them as a single class.

What is Boxing and Unboxing?
Ans. Boxing is the process where any value type can be implicitly converted to a reference type object while Unboxing is the opposite of boxing process where the reference type is converted to a value type.

What does AddressOf in VB.NET operator do?
Ans. The AddressOf operator is used in VB.NET to create a delegate object to a method in order to point to it.

What is XmlHttpRequest in Ajax?
Ans. It is an object in JavaScript that allows the browser to communicate to a web server asynchronously without making a postback.

What does the virtual keyword in C# mean?
Ans. The virtual keyword signifies that the method and property may be overridden.

How to create a new unique ID for a control?
Ans. ControlName.ID = “ControlName” + Guid.NewGuid().ToString(); //Make use of the Guid class

What is the use of the dispose() method in .NET?
Ans. The Dispose method in .NET belongs to IDisposable interface and it is best used to release unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc from the memory. Its performance is better than the finalize() method.

What is the difference between a session object and an application object?
Ans. A session object can persist information between HTTP requests for a particular user, whereas an application object can be used globally for all the users.

Controls in order of has performance, DataGrid, Repeater, DataList?
Ans. Repeater, Datalist, DataGrid.

Is it possible to perform forms authentication with cookies disabled on a browser?
Ans. No, it is not possible.

What is difference between dataset and datareader in ADO.NET?
Ans. A DataReader provides a forward-only and read-only access to data, while the DataSet object can carry more than one table and at the same time hold the relationships between the tables. Also note that a DataReader is used in a connected architecture whereas a Dataset is used in a disconnected architecture.

January 28, 2009

Building AgiliTrain: Part 1 – Why ASP.NET MVC

Filed under: ASP.Net — Tags: — apcig @ 10:47 pm

Shawn Wildermuth recently wrote about his work with ASP.Net MVC.  I’ve heard promising things about it, and listed are some of his points.

  • How I would characterize my experience with ASP.Net MVC… two weeks of a steep learning curve then bliss.
  • The big [fear] … is loss of ViewState. I was never a fan of ViewState and was always perplexed that most projects used WebControls and not nearly enough HtmlControls. HTTP is stateless so in many many situations remaining stateless makes more sense.  Since the HTML controls were lighter weight I tended to use them much more often. That certainly makes my move to MVC easier as I am not bogged down by the loss of ViewState.
  • MVC allows you to write code more like the web. This means doing a lot of AJAX and using jQuery (or Dojo, or whatever you want) as your UI layer.
  • Since I was presenting information that is changing somewhat rapidly that I could develop it faster with ASP.Net MVC.  Not faster in the initial implementation (because I had to learn MVC) but faster to add new functionality as it required it.  I am not positive this is true but in the last few days I’ve been able to add new pieces of functionality to the site pretty easily. It feels a lot more modular than my other sites.
  • The MVC code was mostly clean HTML (no magic ClientID’s or controls) so that integrating was simple.

July 23, 2008

ASP.Net

Filed under: ASP.Net, programming — apcig @ 1:12 pm

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_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 to the actual worker process aspnet_wp.exe.

inetinfo.exe = IIS
aspnet_isapi.dll = ISAPI filter
aspnet_wp.exe = actual worker process

Page Load
Init, Load, PreRender, Unload, Disposed = ILPUD
ViewState is available after Init, OnLoad for a control.

Page Life Cycle Events2

  • Page_Init
    The server controls are loaded and initialized from the Web form’s view state. This is the first step in a Web form’s life cycle.
  • Page_Load
    The server controls are loaded in the page object. View state information is available at this point, so this is where you put code to change control settings or display text on the page.
  • Page_PreRender
    The application is about to render the page object.
  • Page_Unload
    The page is unloaded from memory.
  • Page_Disposed
    The page object is released from memory. This is the last event in the life of a page object.
  • Page_Error
    An unhandled exception occurs.
  • Page_AbortTransaction
    A transaction is aborted.
  • Page_CommitTransaction
    A transaction is accepted.
  • Page_DataBinding
    A server control on the page binds to a data source.
  • Process Request Method finally renders HTML Page

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.

When controls send their events to their parent control to be handled.

What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a “sticky-server” (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.

In-Process stores the session in memory on the web server.
Out-of-Process Session state management stores data in an external data source, requires that all objects stored in session are serializable.

Source: Mark Wagner’s .NET C# Cogitation1

VbDotNetHeaven2

Blog at WordPress.com.