Interview Tips Interview Tips, Interview Questions and Answers

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.

18Mar/110

What is the use of command objects in .NET

They are used to connect connection object to Data reader or dataset. Following are the methods provided by command object:-

• ExecuteNonQuery: -

Executes the command defined in the Command Text property against the connection defined in the Connection property for a query that does not return any row (an UPDATE, DELETE, or INSERT). Returns an Integer indicating the number of rows affected by the query.

• ExecuteReader: -

Executes the command defined in the Command Text property against the connection defined in the Connection property. Returns a "reader" object that is connected to the resulting row set within the database, allowing the rows to be retrieved.

• ExecuteScalar: -

Executes the command defined in the Command Text property against the connection defined in the Connection property. Returns only single value (effectively the first column of the first row of the resulting row set any other returned columns and rows are discarded. It is fast and efficient when only a "singleton" value is required

25Jan/110

Property Set in VBScript

Property Set is very similar to Property Let except that the Property Set procedure is used exclusively for object-based properties. If not explicitly specified using either Public or Private, Property Set procedures are public by default, that is, they are visible to all other procedures in your script. The value of local variables in a Property Set procedure is not preserved between calls to the procedure. You can't define a Property Set procedure inside any other procedure (e.g. Function or Property Let). The Exit Property statement causes an immediate exit from a Property Set procedure. Program execution continues with the statement that follows the statement that called the Property Set procedure. Any number of Exit Property statements can appear anywhere in a Property Set procedure. Like a Function and Property Get procedure, a Property Set procedure is a separate procedure that can take arguments, perform a series of statements, and change the value of its arguments. However, unlike a Function and Property Get procedure, both of which return a value, you can only use a Property Set procedure on the left side of an object reference assignment (Set statement). Note: Every Property Set statement must define at least one argument for the procedure it defines. That argument (or the last argument if there is more than one) contains the actual object reference for the property when the procedure defined by the Property Set statement is invoked. That argument is referred to as reference in the preceding syntax.

16Sep/100

Define LeaseTime, SponsorshipTime, RenewOnCallTime, LeaseManagePollTime in .NET

Terms related to lifecycle of a remoting object.

The LeaseTime property protects the object so that the garbage collector does not destroy it as remoting objects are beyond the scope of the garbage collector. Every object created has a default leasetime for which it will be activated. Once the leasetime expires, the object is eligible again for garbage collector and is eventually destroyed. Default value is 5 minutes.

Even though the leasetime of an object has expired, there still may be clients who would still need the remoting object on the server. In such cases the leasemanager keeps a track of such clients and asks them if they need the object and are ready to extend or sponsor the object to extend its existence. This is done through SponsorshipTime property, which is then based on the sponsor.

The RenewOnCallTime property defines the duration for which a remoting object's lease is extended if a sponsor is found. The default value is 2 minutes.

The LeaseManager class has a property PollTime, which defines the frequency at which the LeaseManager polls the leases. Default is 10 seconds.

18Aug/100

Define Trace Switches

Define Trace Switches.

Trace switches are used to configure tracing behavior.
There are two kinds of trace switches: BooleanSwitch and TraceSwitch.
BooleanSwitch: It is either on or off.
TraceSwitch : It has property to determine trace behaviour.
Trace switches can be configured through application's .config file even after the application is compiled.

What are Trace switches?

Trace switches are used to enable, disable and filter the tracing output. They are objects can be configured through the .config file.

Explain how to implement properties.

You can either use fields or property procedure to add properties.

It is convenient to use fields when the values associated with the properties are less in number. eg: boolean which can have only two values associated with it.

If property procedure has to be used to add a property, then three steps need to be followed:

- Declare a private variable to store the value of the property
- Write a get procedure to retrieve the value of the variable and
- Write a set procedure to set the value of the variable.

29Mar/100

ASP .NET Interview Questions, Part 2

19. Whats an assembly? Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN

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.

29. Name two properties common in every validation control? ControlToValidate property and Text property.

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

34. What does WSDL stand for? (Web Services Description Language)

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.

12Mar/100

simple C# interview question that most developer fails

How do you define a property read only for the outside world and writable for the same assembly classes?

For example I have a class named User where everyone outside the assembly can read the string ‘Name’ property but cannot set it. However the classes inside the assembly is able to set the property.  I am further detailing the exlanation.

User myUser = SomeClass.GetUser();

// OK for all classes since all can read it
string name = myUser.Name;   

// This line does not compile if this code is
// written in a class that is not in the same
// assembly as the type User. But it compiles
// if the code is written in the same assembly
// that contains the type user.
myUser.Name = "C# Developer";

Answer:

Now all I want is the c# code declaration for the property name that matches my requirement of being read only for the outside world. Write it in the comments section. I will answer the question 24 hours from now.

4Mar/100

What is validationsummary server control?where it is used in asp.net?

The ValidationSummary control allows you to summarize the error messages from all validation controls on a Web page in a single location. The summary can be displayed as a list, a bulleted list, or a single paragraph, based on the value of the DisplayMode property. The error message displayed in the ValidationSummary control for each validation control on the page is specified by the ErrorMessage property of each validation control. If the ErrorMessage property of the validation control is not set, no error message is displayed in the ValidationSummary control for that validation control. You can also specify a custom title in the heading section of the ValidationSummary control by setting the HeaderText property.
You can control whether the ValidationSummary control is displayed or hidden by setting the ShowSummary property. The summary can also be displayed in a message box by setting the ShowMessageBox property to true.