Monday, 21 April 2014

Asp.Net Interview Questions- PART 2

Part -2

HTML Server Controls Vs Web Server Controls, Please define?

HTML Server Controls are server-side mapped form of HTML elements. In order to make HTML elements programmable on server-side, ASP.NET framework added runat="server" attribute, so it's accessible in ASP.NET code-behind. A typical HTML Server Control is as follows:
      <input type="text" id="txtFirstName" runat="server" />

On the other hand, Web Server Controls are more feature-rich as compared to HTML server controls and truly designed to provide Win Apps development experience for ASP.NET Web developers. Also, it provides comparatively high level of abstraction. Apart from mapping to existing HTML elements, web server controls provide more rich and complex functionality like Calendar, Grid, Repeater, menu, tree view etc.

So, which one you prefer to use while developing an ASP.NET Web Application?

Although both of these types of controls render HTML elements but Web Server controls being rich in functionality can render additional HTML tags that collectively fulfill control's functionality. On the other hand, HTML Server Controls are comparatively lightweight only producing the corresponding HTML element.

So, preference depends totally on your circumstances. If you are migrating from a classic ASP application to ASP.NET, then only choice is using HTML server controls but if you are going to develop a new application and you wanted to provide rich functionality with ease (i.e. calendar, grid, tree view etc), web server controls are the only choice because we don't have it in HTML server controls.

What is the role of ValidationSummary Control?

Sometimes, we have a requirement that all validation messages need to display at one location (may be top or bottom of a web form). In such scenario, ValidationSummary control displays all validation messages at one place.
DisplayMode property of this control can be used to display in different formats as follows:
  • BulletList
  • List
  • SingleParagraph
We have already provided few questions about Validation Controls in ASP.NET in previous article.


Globalization Vs Localization

There are situations when we need to build an application that work for multiple cultures e.g en-USar-SA etc, this process of designing and building applications that work for more than one cultures is called globalization. However, customizing an application for a specific culture is localization. Both globalization and localization normally go together.

How to access information about a user's locale in ASP.NET?

User's locale information can be accessed through System.Web.UI.Page.Culture property.

Difference between Culture and UICulture properties in ASP.NET?

CultureInfo class plays an important role for localizing our application pages. Culture is specific in localizing
non-visual parts of the page like DateTime, Currency, number formatting etc. while on the other hand, UICulture is specific in localizing visual part of a webpage like Language being used to display the contents of the web page.


Difference between Local and Global resources?

Resources for a localized ASP.NET application can be stored locally as well as globally. Local resources are specific to web page and stored in a folder App_LocalResources. It can be accessible to that specific page only. Global resources are accessed by almost all application pages and stored in App_GlobalResources foler.

What is a Neutral Culture? and how its different from a Specific Culture?

As we have seen earlier that a culture has two things i.e. Language and Country/Region. For example, en-Us represents English - United States; en-GB represents English - Great Britain; and ar-SA represents Arabic - Saudi Arabia. So, we can easily understand that first page is language while second is country/region.

A neutral culture is one that is associated only with part-1 i.e. language and not with part-2 i.e. country/region. For example, ar is the neutral name for Arabic culture while ar-SA is specific to Saudi Arabian Arabic culture.


Difference between Response.Write() and Response.Output.Write()?

Difference between Response.Write() and Response.Output.Write() is that the later provide formatting capability through String.Format-Style which the former doesn't have.
In case of Response.Write(), HttpResponse calls directly the following method:
      public void Write(object obj)
     {  
this._writer.Write(obj);
     }
Above method internally calls it TextWriter's write() method.
However, in case of Response.Output.Writer(), HttpResponse actually get reference to TextWriter through
Reponse.Output and then after getting control TextWtiter, call other overloaded method that helps to format the string.
       Response.Output.Write("This is an {0} test at {1:d}", "amazing", DateTime.Now);

No comments:

Post a Comment