ASP.NET Interview Questions and Answers (1544) - Page 4

What is ViewState ? and how it is managed ?

ASP.NET ViewState is a new kind of state service that developers can use to track UI state on a per-user basis. Internally it uses an an old Web programming trick-roundtripping? state in a hidden form field and bakes it right into the page-processing framework.It needs less code to write and maintain state in your Web-based forms.
What is meant by urlencode and urldecode?

urlencode() returns the URL encoded version of the given string. URL coding converts special characters into % signs followed by two hex digits. For example: urlencode(”10.00%”) will return “10%2E00%25?. URL encoded strings are safe to be used as part of URLs.
urldecode() returns the URL decoded version of the given string.
How’s the DLL Hell problem solved in .NET ?

Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
What’s the difference between System.String and System.StringBuilder classes?

System.String is immutable; System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.Append Keyword is used in System.StringBuilder but not in System.String.
Why only boxed types can be unboxed?

Unboxing is the process of converting a Reference type variable to Value type and thus allocating memory on the stack . It happens only to those Reference type variables that have been earlier created by Boxing of a Value Type , therefore internally they contain a value type , which can be obtained through explicit casting . For any other Reference type , they don’t internally contain a Value type to Unboxed via explicit casting . This is why only boxed types can be unboxed.
Between Windows Authentication and SQL Server Authentication, which one is trusted and which one is untrusted?

Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction.
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.
What is the difference GridView and between DataGrid(Windows)?

GridView :

1) GridView Control Enables you to add sorting,pagingand editing capabilities without writing any code.

2)GridView Control Automatically Supports paging by setting the ‘PagerSetting’ Property.The Page Setting Property supports four Modles
a. Numeric(by default)
b. Next Previous
c. NumericFirstLast
d. Next PreviousLast

3)It is Used in asp.net

4)GridView Supports RowUpdating and RowUpdated Events.

5)GidView is Capable of Pre-Operations and Post-Operations.

6)GridView Has EditTemplates for this control

7)It has AutoFormat

DataGrid(Windows)

1)DataGid Control raises single Event for operations

2)DataGird Supports the SortCommand Events that occur when a column is Soted.

3)DataGrid Supports UpdataCommand Event that occurs when the UpdateButton is clicked for an item in the grid.

4)DataGrid is used in Windows GUI Application.

5)It doesnot have EditTemplates for this control

6)It doesnot have AutoFormat
Difference between DataGrid, DataLsit and Repeater?

Difference between DataGrid, DataLsit and Repeater?

DataGrid:

1) DataGird has a in-built Support for Sort, Filter, and Paging the Data.

2) Each Row in DataGrid is displayed as a row in the table.

3) It has an AutoGenarateColumn Property, which can be set to either True or False.
Default property is true.

4) DataGrid has predefined Editing Controls.

5)Following are the DataGrid Data Control Styles:

i. AlternatingItemStyle
ii. EditItemStyle
iii. FooterStyle
iv. HeaderStyle
v. ItemStyle
vi. SelectedItemStyle
vii. PagerStyle

6) Following are the DataGrid Data Control Templates(only supported by the TemplateColumna) :

i. HeaderTemplate
ii. ItemTemplate
iii. EditItemTemplate
iv. FooterTemplate



DataList:

1) Support Paging, Sorting and editing but explicitly code to do Paging.

2) It displays the Records in Tabular form.

3) By default the DataList Displays its Data in a HTML .

4) You can specify via the repeat columns how many DataSource records should appear HTML .

Eg :

5)DataList Doesnot have Predefined Editing Controls.


6) Following are the Data Grid Data Control Styles:

i. AlternatingItemStyle
ii. EditItemStyle
iii. FooterStyle
iv. HeaderStyle
v. ItemStyle
vi. SelectedItemStyle
vii. SeparatorStyle

7) Following are DataList Data Control Templates:

i. AleternatingItemTemplate
ii. EditItemTempalte
iii. HeaderTemplate
iv. ItemTempalte
v. SelectedItemTemplate
vi. SeparatorTemplate
vii. SelectedItemTemplate
viii. FooterTemplate

Repeater:

1) It can be used for lightweight and simple report generation.

2) It is used to display a Repeated List of items that are bound to the control.

3) It does not support Paging.

4) Repeater is faster followed by DataList and finally DataGrid.

5) To create a table in a Repeater you must include the begin table tag in the HeaderTemplate,a single table row tag in the ItemTemplate and the end table tag
in the FooterTemplate

6)No predefined Styles

7) Following are Repeater Data Control Templates:

i. FooterTemplate
What is the difference between Server.Transfer and Response.Redirect?

Both "Server" and "Response" are objects of ASP.NET. Server.Transfer and Response.Redirect both are used to transfer a user from one page to another. But there is an underlying difference.
//Usage of Server.Transfer & Response.Redirect
Server.Transfer("Page2.aspx");
Response.Redirect("Page2.aspx");
The Response.Redirect statement sends a command back to the browser to request the next page from the server. This extra round-trip is often inefficient and unnecessary, but this established standard works very well. By the time Page2 is requested, Page1 has been flushed from the server’s memory and no information can be retrieved about it unless the developer explicitly saved the information using some technique like session, cookie, application, cache etc.

The more efficient Server.Transfer method simply renders the next page to the browser without an extra round trip. Variables can stay in scope and Page2 can read properties directly from Page1 because it’s still in memory. This technique would be ideal if it wasn’t for the fact that the browser is never notified that the page has changed. Therefore, the address bar in the browser will still show “Page1.aspx” even though the Server.Transfer statement actually caused Page2.aspx to be rendered instead. This may occasionally be a good thing from a security perspective, it often causes problems related to the browser being out of touch with the server. Say, the user reloads the page, the browser will request Page1.aspx instead of the true page (Page2.aspx) that they were viewing. In most cases, Response.Redirect and Server.Transfer can be used interchangeably. But in some cases, efficiency or usability may be the deciding factor in choosing.
which of the following controls support databinding.

NOTE: This is objective type question, Please click question title for correct answer.
difference between custom control and user control

User control

1) Reusability web page
2) We can’t add to toolbox
3) Just drag and drop from solution explorer to page (aspx)
4) U can register user control to. Aspx page by Register tag
5) A separate copy of the control is required in each application
6) Good for static layout
7) Easier to create
8)Not complied into DLL
9) Here page (user page) can be converted as control then
We can use as control in aspx

Custom controls

1) Reusability of control (or extend functionalities of existing control)
2) We can add toolbox
3) Just drag and drop from toolbox
4) U can register user control to. Aspx page by Register tag
5) A single copy of the control is required in each application
6) Good for dynamics layout
7) Hard to create
8) Compiled in to dll
What is the difference between Session Cookies and Persistent Cookies?

Persistent Cookies are same as Session Cookies except that, persistent cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client's hard drive
. Keep in mind that because a user can delete cookies from their machine that there is no guarantee that a cookie you "drop" on a user machine will be there the next time they visit your site.
What is Cookie Dictionary?

A cookie dictionary is a single cookie object that stores multiple pieces of information. You use the Values property to access and assign new values to the cookie dictionary.
What are the advantages and disadvantages of Cookies?

Advantages
1. Cookies do not require any server resources since they are stored on the client.
2. Cookies are easy to implement.
3. You can configure cookies to expire when the browser session ends (session cookies) or they can exist for a specified length of time on the client computer (persistent cookies).
Disadvantages
1. Users can delete a cookies.
2. Users browser can refuse cookies,so your code has to anticipate that possibility.
3. Cookies exist as plain text on the client machine and they may pose a possible security risk as anyone can open and tamper with cookies.vv
Which one is not the correct ASP.NET Version?

NOTE: This is objective type question, Please click question title for correct answer.
What are server controls?

ASP.NET server controls are components that run on the server and encapsulate user-interface and other related functionality. They are used in ASP.NET pages and in ASP.NET code-behind classes.
Difference between ASP Session and ASP.NET Session?

asp.net session supports cookie less session & it can span across multiple servers.
What is cookie less session? How it works?

By default, ASP.NET will store the session state in the same process that processes the request, just as ASP does. If cookies are not available, a session can be tracked by adding a session identifier to the URL. This can be enabled by setting the following:
<sessionState cookieless="true" />

http://samples.gotdotnet.com/quickstart/aspplus/doc/stateoverview.aspx
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories