Interview Tips Interview Tips, Interview Questions and Answers

29Jun/110

What is OOP?

OOPs - Object Oriented Programming Languages & Systems
Everything in the world is an object. The type of the object may vary. In OOPS, we get the power to create objects of our own, as & when required. OOPs is a programming methodology where each entity is an object.
It is a method of computer programming where entities of related data together with routines associated with it are treated as one object in the program.

22Jun/110

ASP.Net Listview Databinding

ASP. Net ListView DataBinding

For presenting data like a list, we have tons of options in Asp.Net like ListView, DataList, Repeater, GridView, DropDownList, etc... Since we have a array of controls to choose from, the control can be selected based on specific requirements. For e.g. there is a need of selecting a single column then DropDownList is the perfect choice. If paging, sorting, edit is required then GridView will be the ideal choice. If just need to repeat some html code, then Repeater will work out to be better. This article is mainly focused on VB.Net ListView DataBinding.
DataBinding is quiet similar to GridView

DataBinding in ListView is almost similar to GridView. There is not much noticeable difference. There should be atleast one ItemPlaceHolder present in the template. By default the name of that is itemPlaceholder. Asp.Net allows us to custom name (id) also for easy reading.
Flexibility in rendering

This ListView is one of the best controls while flexibility is taken into consideration. With the concept of Item Place Holder, we can specify/ configure where the items have to be placed (rotated). In this example, I have made a two column liquid layout . The number of horizontal cells can be adjusted based on the resolution while resizing the browser.
Templates in ListView

There are few templates that will ease the development effort using ListView. If you have worked in GridView earlier, then basic templates in ListView are similar to GridView Templates. There are few special templates. I am highlighting the templates in the following list. These templates can be used customize rendering.

LayoutTemplate
GroupTemplate
ItemTemplate
AlternatingItemTemplate
EditItemTemplate
InsertItemTemplate
ItemSeparatorTemplate
GroupSeparatorTemplate
EmptyItemTemplate
EmptyDataTemplate
SelectedItemTemplate

18Jun/110

how to upload an excel in c# ASP.Net?

protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (fuUpload.HasFile)
        {
            string filename = fuUpload.PostedFile.FileName;

            string strConn;
            strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
+"Data Source="+ filename +";" +"Extended Properties=Excel
8.0;";
            OleDbConnection con = new OleDbConnection(strConn);
            con.Open();
            OleDbCommand cmd = new OleDbCommand("select *
from [Sheet1$]",con);
            OleDbDataAdapter dad = new OleDbDataAdapter();
            dad.SelectCommand = cmd;
            DataSet ds= new DataSet();
            dad.Fill(ds);
            DataGrid1.DataSource = ds.Tables[0].DefaultView;
            DataGrid1.DataBind();
            con.Close();
        }

    }
12Jun/110

Powerpacked new controls in Microsoft ASP.NET 3.5

DataPager - Controls like Gridview, Repeater exhibit the pagination behaviour. This is useful when display results return far too many records than an ideal web page height. A search may return countless records, but the web page size should not ideally go on and on depending on the number of records returned. For this, the feature of Page Numbers, OR Previous-Next feature at the bottom of the display results seem to be more ideal. For this purpose, the DataPager control has been introduced.

While using a ListView control, a DataPager control may be used along with it, to provide a paging functionality. The DataPager has a property called PagerControlId which is set to the ID of the ListView control. Simple!

ListView - This control is like an advanced Repeater control, and is as good as a GridView control in terms of features it has. It may be set to any standard data source like SQL, Oracle, Access, XML and even LINQ.

Say you want to display a matrix of values with 3 records per row, the ListView control is the ideal solution. The ListView settings may be made manually using the aspx page, OR may also be set using the Smart Tag feature to launch the properties dialog box.

ScriptManager - Every Ajax enabled page in ASP.NET that makes use of the Ajax Library needs to have a boss or a  manager that takes care of the internal Ajaxification process. All this is controlled by the ScriptManager control. Every page should have not more than one ScriptManager control. It takes care of the javascript functionalities, partial postbacks made by the web page by taking care of the XmlHttpRequest object from behind the scenes. More on Ajax, Read Here.

If the EnablePartialPostback property of the ScriptManager is set to false, the web page exhibits a full page postback.

ScriptManagerProxy - There might be a scenario where your master page and content page need to have separate ScriptManager controls. For such situations, the ScriptManagerProxy control comes to rescue. Here, the masterpage may contain the ScriptManager control, and the content page may use the ScriptManagerProxy control. However, internally, the ScripManagerProxy control communicates with the corresponding ScriptManager  class of the web page. The ScriptManagerProxy control actually transfers its set of responsibilities to the ScriptManager control.

UpdatePanel - This is the control that wraps all the controls that need to be partially posted back. A web page may comprise of several UpdatePanels. In case there is any event happening within the controls wrapped inside an UpdatePanel control, the entire page isn't posted back, rather only the contents within the UpdatePanel are posted back to the web server. If the partial postback property is to be avoided, set the ChildrenAsTriggers property of the UpdatePanel to false.

Further, the Triggers of an UpdatePanel may be used to set the application in such a way that the partial postback of the UpdatePanel may be invoked from controls that lie outside the UpdatePanel.

UpdateProgress - There are scenarios where a request may take time, an image may take time to load, a business logic may time to calculate, data may take time to load due to diversities in the source. In UpdatePanels, as postbacks are partial in nature, the browser's default progress bar does not appear. For avoiding any confusion to the end user, that a page process is going on in the background, the UpdateProgress control may be used. This is like a progress bar that shows to the end user that a process is going on. The progress may be set to any moving gif image as well, to enhance the look & feel of the web application.

1Jun/110

C# interview questions and answers

  1. What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.
  2. What does the This window show in the debugger? It points to the object that’s pointed to by this reference. Object’s instance data is shown.
  3. What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
  4. What’s the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
  5. Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities.
  6. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor.
  7. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger.
  8. What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).
  9. Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.
  10. Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources).