Saturday, April 24, 2010

ASP.NET Interview Questions


Few days back I was asked by my employer to prepare some interview questions on asp.net and sqlserver for the purpose of written test. I am providing few of the interview questions with answers for the same. Let me know your ideas on the topic.



  1. What is the interface we need to implement in order to create a HTTP Handler
    1. IMyHandler
    2. IHttpHandler
    3. IHttpHandlerFactory
    4. None of the above


  2. What is the fastest way to retrieve data from the database
    1. Use DataTable
    2. Use DataAdapter
    3. Use Dataset
    4. Use DataReader
Reason:Because DataAdapter internally makes use of DataReader class.



  1. What is the correct answer among the following regarding the ViewState
    1. It is used to Create the visibility on the Web pages
    2. It is used to Maintain the State of the User as long as he surf the website
    3. It is used to maintain the state between the subsequent requests within a page
    4. It is used to increase the performance of the web application


  2. When does the Session_Start event in the Global.asax fire,
    1. When a new user starts using the application
    2. When the user logs into the server using the Login.aspx page
    3. When a user requests a secured page
    4. When first user sends a request


  3. There is a Master page called MyApplication.master and a content page called MyContentPage.aspx. When we run the application which of the following events will take place first
    1. Page load event in the MyApplication.master
    2. Page load event in the MyContentPage.aspx
    3. PreInit event in the MyApplication.master
    4. PreInit event in the MyContentPage.aspx
Reason:Because you have the capability to change the master page at run time in the PreInit event of the content page.



  1. You need to execute code conditionally, depending on whether the page is generated in response to a server control event on the same page. How would you check this programmatically?
    1. Page.HasControls
    2. Page.IsCrossPagePostBack
    3. Page.IsPostBack
    4. Page.IsCallback


  2. In which folder you can place the SqlServer Express Edition
    1. App_Data
    2. App_Code
    3. App_Themes
    4. App_LocalResources
App_Data folder is used to store the .mdf files in asp.net (Introduced in 2.0).

App_Code folder is used to store the class files in asp.net (Introduced in 2.0).

App_Themes is used to store the skins, themes etc (Introduced in 2.0).

App_LocalResources is used to store the resource information in asp.net.



  1. There is a class called as MyClass in C#. When initializing the class in Using block as,
    MyClass obj = new MyClass();
    using(obj)
    {
    //Some Code to follow..
    }
    The above application resulted in error. What could be the reason,

  1. We cannot use "using" block for the Custom classes
  2. MyClass must implement IDisposable interface
  3. The obj must be declared in try, catch block
  4. using block cannot be used in ASP.NET, that is only related to C#
Reason:The using block will call the dispose method automatically when the scope of the using block is ended.



  1. If one has two different web form controls in application and if one wanted to
    know whether the values in the above two different web form control match what
    control must be used.
    1. DataGrid Control
    2. CompareValidator
    3. TextBox Validator
    4. ListView Control


  2. Which of the following denote ways to manage state in an ASP.Net Application?
    1. Session Objects
    2. Application Objects
    3. View State
    4. All of the above


  3. In ASP.NET the < authorization > section contain which of the following
    elements
    1. <deny>
    2. <allow>
    3. Both A and B
    4. None of the above


  4. What is the easiest way to handle all the exceptions in a web application
    1. Use try.. catch block for all the methods
    2. Use Error handler at the page level in each page
    3. Use Application level Error handler at Global.asax
    4. Create a section in web.config file that can handle all the errors


  5. What is AJAX?
    1. It is a technology that enables browsers to render information faster than normal way
    2. It is a technology which enables javascript to do high graphics on the web pages
    3. It is a latest version of the Web Services
    4. None of the above


  6. What are the datasource controls available in ASP.NET
    1. SqlDataSource
    2. ObjectDataSource
    3. XmlDataSource


    4. All of the Above




  7. How do you Cache a DataTable
    1. By using Cache object
    2. By saving the DataTable to xml file and keeping in memory
    3. Writing the Page Output Cache attribute on the page control
    4. Creating a user control for a DataTable


  8. Trace and debug classes belong to which Namespace
    1. System.Diagnostics
    2. System.Reflection
    3. System.Data
    4. None of the above


  9. Column mappings belongs to which namespace
    1. System.Data
    2. System.Data.Common
    3. System.Xml
    4. System.Data.Relations
     I will post the remaining ASP.NET Interview questions and Sql Server Interview Question to the blog as soon as possible.

Thursday, April 22, 2010

Memory usage details of the Browsers in Google Chrome

Google Chrome is a browser released from Google. The browser contains an interesting feature that shows the memory statics of all the opened browsers. The memory details will be shown on the basis of Private and Shared Memory used by a particular browser. In addition to this, it also shows the details of Chrome's individual tab details. To check this we can make use of the following steps,

1. Open Google Chrome
2. In the address bar type about:memory where we usually type the url.

The same procedure will also works for Mozilla Firefox. The firefox shows the details of firefox browser. In observations on the three browsers namely Internet Explorer 7, Firefox 3.6 and Google Chrome I found that Internet Explorer 7 is the one which uses the less memory and Firefox is the browser which utilizes the more memory.

Chrome is a freeware browser available for download here

Thursday, January 14, 2010

Beginning the jQuery - Get the Element by it's ID

What is meant by jQuery?

Well.. to be simple, jQuery is nothing but javascript library. As we people know SQL is a Structured Query Language for retrieving and manipulating data stored in database, and XQuery for XML. In the same way jQuery is a javascript library to retrieve and manipulate the HTML in a very easy and friendly manner.

What we need to work with jQuery?

All we need to work with jQuery is the jQuery library, which is available at http://jquery.com/ and http://www.google.com/support/blogger/bin/answer.py?hl=en&answer=42051. At the time of this writing the jQuery's version is 1.3.2. This is a library with around 55.9 kb, which is perfectly acceptable for the work it will offer.

Let's begin with..

As my intention is to make every one free to work with jQuery. So, in this blog entry I am not going to explain all the complex details included with in. I will provide a very simple example that is very much useful for all the beginners.

Find Element By ID..

The biggest trouble that most of the developers feel at any time is getting the reference to the control in javascript by using document.getElementById() method or something similar. However, this method won't work perfectly many times. The reason is simple, it fails due to incompatibility with the browsers, Inner controls(the control may be present inside some other control such as div etc) etc.

To overcome such kind of issues jQuery addresses a very simple way to get the reference of the required control. In this simple demonstration I will provide a user to enter some value to a text box( input type="text"). And on a button click the text goes to the span tag. This sounds very simple, but this will be really great feature when it comes to large complex page.

Here is the HTML code for this example,

<div>
Name:
<input type="text" id="getName" />
<button id="clickMe">
Display My Name in Span
<br />
</div>
<span id="mySpan">This is the text appeared in span tags

And the jQuery code is very simple as around 3-5 lines to accomplish this task,

<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("#clickMe").click(function(){
$("#mySpan").text($("#getName").val());
});
});
</script>


For the moment you forgot about the first lines such as $(document).ready(function()..)}; etc, because I don't want to make you scare by explaining all the complicated details with in this. Think this as a standard for all your future jquery coding.

So at the moment, let us concentrate how to retrieve the value of getName text box. This is very simple as,
$("#getName").val();

Yes, this is where we are passing the id of any control with the prefix of #.
The val() is a function provided by jQuery to get the value in that particular control. This works for all the HTML controls that supports value attribute.
Remember all the jQuery coding should be enclosed with in the brackets as $(..). However we can replace with any other symbols which is out of discussion in the entry. And now we got the reference to the control span by passing it's id as,

$("#mySpan").val() and for button as $("#clickMe") etc..

and the function click() is the event handler for the button.

You can download the source code for this simple solution here. In the future version of this blog, I am going to explain all the jQuery features one by one and later we can move to the most advanced features of the jQuery such as working with jQuery Plugins. If you frequently follow this blog you are going to be create your own jQuery plugin on one day.