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

Name two properties common in every validation control?

ControlToValidate property and Text property.
What is the lifespan for items stored in viewstate

Item stored in ViewState exist for the life of the current
page. This includes postbacks (to the same page).
How to start NotePad file in AsP.NET with code ?

System.Diagnostics.Process.Start("Notepad.exe");
With wchich function you can get integer value for the specified part of the specified date ?

NOTE: This is objective type question, Please click question title for correct answer.
A textbox generally gets named as "ctl00$Body$txtClientName". Can you control naming of the same?

With the latest release of VS 2010, the answer gets changed to “Yes” from “No”.
Runtime naming of the controls were generally handled by complex algorithms running behind with the application. But it was overhead with length of the control names.
With the VS 2010, now user can define pattern of the control naming.
This function returns character string representing the specified datepart of the specified date.

NOTE: This is objective type question, Please click question title for correct answer.
Is “var i = (i = “test”);” possible ?

No. It is not possible. Variabled declared with “Var” can not be used in its initialization statement as you can do with explicit data. (int i=(i=”test”);
Which one is faster – DirectCast or CTYpe.

DirectCast.
CType uses the Visual Basic run-time helper routines for conversion which makes it slower then DirectCast.
Thumbrule for DirectCast

One type must inherit from or implement the other type
DirectCast generates a compiler error if it detects that no inheritance or implementation relationship exists
What will it result… CInt(1.8) CInt(-1.8) CInt(-1.2)

NOTE: This is objective type question, Please click question title for correct answer.
How to Invoke the Server Code on the Click of Checkbox in a DataGrid column.

As there is no CommandName property of Checkbox so when in Datagrid or any databound control give the AutoPostBack to True and bind to its event "OnCheckedChanged" and define it in the Server Code, it will work.
How to print out all the variables in the Session?

Yes, Using "Session.Keys" we can get all session variables

In VB.NET

Dim strSesVar as string
For Each strSesVar In Session.Keys
Response.Write(strSesVar + " : " + Session(strSesVar).ToString() + "<br>")
Next


In C#

foreach (string strSesVar in Session.Keys)
{
Response.Write(strSesVar + " : " + Session[strSesVar].ToString() + "<br>");
}
All session content can be Removed ?

Yes, All session content can be Removed using following codes :

Session.Contents.RemoveAll()

it Removes all items from current Session.
Is there any difference between UCase and toUpper?

With concern of the functionality both of these works same. The most evaluated parameter has been performance - even with that it is minor of 5-7%. So unless, you have millions iterations to be performed with strings, you don't have to get worried about the performance of them.
String functions are faster.
The same is true with toLower and LCase.
Is it possible to delete application’s all setting?

Yes, it is possible with DeleteSetting function.
The function can take 3 arguments of application name, section name and key name.
If all of these are present then it deletes the specified key. But in case if you have specified only first argument of application name, it deletes all settings.
DeleteSettings(“testApp”) ‘ Deletes all setting of testapp
Is it possible to delete application level settings if you have not logged in to application?

If you are using DeleteSetting function to accomplish the requirement then it is not possible. As DeleteSetting function requires to access the HKEY_LOCAL_USER registry key, which is not active until a user logs on interactively.
What are the common security threats for any asp.net application?

Common threats are:

1. Cross side scripting
2. SQL Injection
3. Storing Password in simple format.
4. No validation for user input.
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