ASP.Net Interview Questions and Answers

    16 Votes

108) What are the common properties Button controls used in ASP.NET?
Following are the list of properties used –
  • Text – This property is used to display the text of button.
  • CausesValidation – This property is used to determine whether validation occurs in page once button is clicked.
  • ImageUrl – This property is used for displaying the image on button control.
  • CommandName - This property is used to get or set the command name associated to button control.
  • CommandArgument – This property is used for passing the string value to command event once user clicks on button.

109) What is a component?

Component is a group of classes and methods which are logically related. Component should implement IComponent interface or at least uses class that implemented IComponent interface.

110) How to force all the validation control to run?
Page.Validate method is used to force all the validation controls to run.

111) If client side validation is enabled in your Web page, will that mean server side code does not run?

When client side validation is enabled, server emits JavaScript code for the custom validators. But, it does not mean that server side checks on custom validators do not execute. It does this check two times as some of the validators do not support client side scripting.

112) How can I show the entire validation error message in a message box on the client side?

This can be done by setting “ShowMessageBox” to true of validation summary.

113) How to validate textbox for zero value?

Below is a code snippet for custom validator, which is checking whether a textbox have a zero value –

<asp:CustomValidator id="MyTestCustomValidator" 
ErrorMessage="Divided by Zero Error"
ControlToValidate=" txtTestMyNumber"
ClientValidationFunction="CheckZero" />
<asp:TextBox id="txtTestMyNumber" runat="server" />
<script language="javascript">
function CheckZero(source, args)
int val = parseInt(args.Value, 8);
if (val ==0)
args.IsValid = false;

As shown above “txtNumber” is the text box name where in value will be entered and client script “CheckZero” checking for zero value.

114) If cookies are not enabled at browser end does Form Authentication work?

No. it will not work. Form authentication wants cookies to be enabled.

Reason – First time user will send its credentials to server and user will then be authenticated and server gives a response and this will be stored in client machine mainly as cookie. But if cookies are disabled, this would not be stored. For the second time, the same user will not be authenticated.

115) How do I sign out in forms authentication?

FormsAuthentication.Signout() method is used to sign out.

116) What are design patterns?

It is recurring solution to recurring problems in software architecture.

117) Can you list down all design patterns?

Below are the list of design patterns along with their classifications -

Creational Design Pattern

  • Abstract Factory
  • Builder
  • Factory Method
  • Singleton
  • Prototype

Structural Design Patterns

  • Composite
  • Adapter
  • Flyweight
  • Proxy
  • Decorator
  • Bridge
  • Façade

Behavioral Design Patterns

  • Interpreter
  • Iterator
  • Command
  • Observer
  • Mediator
  • Template Method
  • Strategy
  • Chain of Responsibility
  • State
  • Memento
  • Visitor

118) How to customize columns in GridView?

Gridview have the ability to generate required columns automatically using BoundField. But, we can manually create column which are to be customized instead of auto generating. For customizing columns “TemplateField” will be used.

119) Can we use COM components in .Net? If so, how can we use?

Runtime Callable Wrapper” (RCW) can be used for making communication between COM components and .NET components.

This can used in following ways –

  • Create a wrapper class and put it in BIN directory.
  • Use type library importer tool - Tlbimp.exe
  • Use namespace System.Runtime.Interopservices , which gives converter (TypeLib) which has all methods which are required to convert COM classes to assembly metadata.

120) How can I show the entire validation error message in a message box on the client side?

This can be done by adding validation summary control. In Validation Summary control, there is a property “ShowMessageBox” just set it to true.

121) List down the differences between Debug and Trace in ASP.NET?

Both these methods are under namespace - System.Diagnoastics.

  • Debug – This works only when the mode is Debug.
  • Trace – This works in both Debug and Release modes.

122) What is the difference between Process and Thread?

  • Process is collection of system resources, data, code and memory space.
  • Thread is a code which is executed in process. One process can have multiple threads along with primary thread. Thread will be executed until it’s killed or higher priority thread comes for an execution. Each thread will share resources of a process in which it is running.

123) What is the difference between cache object and session object?

  • Cache – This improves the performance by minimizing the database hits to fetch the data. It instead stores the data in cache. So cache will be checked first for data and if it is not found then go to database to get the data.
  • Session – Session will be created to store the details of the user for capturing the user’s specific actions. Session will be killed or it will be expired in 20 minutes.
Page 8 of 10

Popular Videos


How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

C# Interview Questions
.Net Framework Interview Questions and Answers
ADO.Net Interview Questions and Answers for Freshers, Experienced
ASP.Net MVC Interview questions and Answers
WCF Interview Questions and Answers
ASP.Net Web API Interview Questions
Top 50 Entity framework interview questions & answers