Asp.Net Interview Questions (Part-2)

Which is the parent class of the Web server control?

The System.Web.UI.Control class is the parent class for all Web server control.

Why do we need nested master pages in a Web site?

When we have several hierarchical levels in a Web site, then we use nested master pages in the Web site.

How can you dynamically add user controls to a page?

It is possible to load User Controls onto a page by making use of the LoadControl method.

TestUserControl tuc = (TestUserControl)LoadControl("TestUserControl.ascx");

Once the User Control has been loaded, it can be added to the page by adding it to the Controls collection.


How can you implement the postback property of an ASP.NET control?

A postback refers to the complete round trip journey made by a client, typically a web browser, from the client to the server and then back to the client. In order to enable the postback functionality for controls, it is necessary to set the AutoPostBack property to True. This property configuration ensures that the controls trigger the postback mechanism, allowing for the exchange of data and information between the client and server seamlessly. By enabling AutoPostBack, the controls are designed to initiate the necessary server-side processing, execute the required actions, and deliver the updated response back to the client, facilitating interactive and dynamic web applications.

What are the Navigations technique in ASP.NET?

  1. Response.Redirect
  2. Server.Transfer
  3. Server.Exceute
  4. Cross page posting

What is a round trip?

A round trip occurs when an event is triggered on a control, which subsequently travels back to the server for the necessary processing. When employing Response.Redirect, the process involves sending a request for the new page to the browser (HTTP 302 Found), followed by the browser requesting the new page from the webserver (HTTP 200 Ok). Consequently, the page changes occur. However, when utilizing Server.Transfer, the communication directly takes place with the server to switch pages, thereby bypassing an entire round trip in the overall process. This optimization in Server.Transfer helps to reduce unnecessary overhead and enhances the efficiency of the page transition.

What is WebParts in ASP.NET?

Web Parts is a comprehensive collection of controls integrated into the ASP.NET server control framework, providing a powerful toolset for constructing dynamic web pages that empower end users to directly manipulate the content, appearance, and behavior of the website through their browser. These Web Parts controls function similarly to other ASP.NET server controls, allowing developers to utilize a wide range of existing ASP.NET controls, such as standard web server controls, custom server controls, and user controls, as Web Parts controls. This versatility enables developers to create interactive and customizable web experiences, empowering users to personalize and tailor the website according to their preferences and requirements.

Can I deploy the application without deploying the source code on the server?

Yes. Deploying an ASP.NET application without exposing the source code on the server can be achieved by deploying the compiled version of the application. To accomplish this, you can utilize the aspnet_compiler.exe tool, which enables you to precompile the entire site. During this precompilation process, each page within your web application is transformed into a singular application DLL, along with the inclusion of placeholder files. Subsequently, these compiled files can be safely deployed onto the server, ensuring that the source code remains inaccessible while still allowing the application to function seamlessly. This approach enhances security by safeguarding the intellectual property and proprietary code, while enabling efficient deployment and maintenance of the application in a production environment.

How can you display all validation messages in one control?

You can use the ValidationSummary control to displays all validation messages in one control. It is possible to set the HeaderText to something like "(*) Fields are required" to your validation summary.

Which method is used to force all the validation controls to run?

The Page.Validate() method is used to force all the validation controls to run and to perform validation.

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

In validation summary set "ShowMessageBox" to true.

What is ValidationSummary?

The ValidationSummary control provides a convenient way to present a consolidated summary of all validation errors encountered. By utilizing the ShowSummary property, you have the ability to toggle the visibility of the ValidationSummary control, allowing for control over its display. Furthermore, if desired, you can choose to present the summary within a message box by setting the ShowMessageBox property to true. In the absence of an explicitly assigned value to the Text property, the ErrorMessage property is automatically utilized to populate both the ValidationSummary control and the body of the page, ensuring consistency in error messaging throughout the application. This comprehensive approach to error handling and reporting enhances the user experience by presenting a concise and easily understandable summary of validation errors.

What data type does the RangeValidator control support?

  1. Currency
  2. Date
  3. Double
  4. Integer
  5. String

Which control will you use to ensure that the values in two different controls match?

CompareValidator. It compares the value entered by the user in an input control with the value entered in another input control.

What is the difference between a HyperLink control and a LinkButton control?

The Hyperlink control, an HTML control, facilitates page navigation when clicked by the user. Upon activation, it redirects the page to the designated target page. On the other hand, the ASP.NET LinkButton control serves as a server control, triggering a request to be sent back to the server upon user interaction. The server then responds by navigating the page to the specified target page. This server-client interaction ensures seamless navigation and dynamic behavior within the ASP.NET application, providing a smooth and interactive user experience.

What does the Orientation property do in a Menu control?

To control the rendering direction of the Menu control, you can utilize the Orientation property. This property allows you to specify whether the menu should be rendered horizontally or vertically by selecting from the Orientation enumeration. When the Orientation property is set to Horizontal, the menu control is rendered in a horizontal layout, while setting it to Vertical instructs the menu control to be rendered in a vertical layout. By effectively using the Orientation property, you can precisely tailor the presentation of the Menu control to align with your desired design and user experience.

How information about the user's locale can be accessed?

The information regarding a user's locale can be accessed by using the System.Web.UI.Page.Culture property.

How do you sign out from forms authentication?

The method FormsAuthentication.SignOut() is used for sign out from forms authentication.

What is a multilingual website?

A multilingual website refers to a website that offers content in multiple languages, catering to a diverse audience. Such websites provide users with the ability to access content in different languages, accommodating their language preferences and ensuring a localized experience. There are various approaches to implementing multilingual sites. One approach involves offering language selection options to users, allowing them to choose their preferred language. Subsequently, the website dynamically presents the content in the selected language, providing a tailored experience to each user. By supporting multiple languages, a multilingual website enhances accessibility, user engagement, and global reach, supporting effective communication and promoting inclusivity.

What is the difference between a default skin and a named skin?

When applying themes to a web page, a default skin serves as a pre-defined style that automatically encompasses all controls of a specific type When a theme is applied to a page, the default skin seamlessly applies to each control of the corresponding type, ensuring consistent visual appearance throughout the page. On the other hand, a named skin functions differently, as it does not apply to controls of the same type automatically. Instead, to assign a named skin to a specific control, you explicitly set the control's SkinID property, indicating the desired skin to be applied. This explicit assignment allows for more granular control over the styling of individual controls within the page, enabling customization and flexibility in the appearance of each control.

What are the different validators in ASP.NET?

  1. RequiredFieldValidator
  2. RangeValidator
  3. CompareValidator
  4. RegularExpressionValidator
  5. CustomValidator
  6. ValidationSummary

Which protocol is used to call a Web service?

Simple Object Access Protocol (SOAP) is widely recognized as the recommended protocol for enabling communication and interoperability between web service-enabled applications. SOAP establishes a standardized XML-based message format that facilitates seamless interaction between these applications across the web. By adhering to SOAP specifications, web services can exchange information and perform actions in a consistent and reliable manner, promoting compatibility and effective integration across diverse systems and platforms.

What is the file extension of web service?

ASMX (.asmx) is extension for Webservices.

How do you register JavaScript for webcontrols ?

You can register javascript for controls using

<CONTROL -name > .Attribtues.Add(scriptname,scripttext) method.

In which event are the controls fully loaded?

Page_Load event.

Controls are also accessed in Page_Init events but view state is not fully loaded during this event.

What is side-by-side execution?

ASP.NET applications are deemed to be running side by side when they are deployed on a single computer but utilize distinct versions of the .NET Framework. This capability enables the concurrent execution of multiple iterations of an application or component on a shared computing environment. It allows for the coexistence of multiple versions of the common language runtime and enables the simultaneous presence of various applications and components, each utilizing a specific version of the runtime, on the same machine. This feature promotes flexibility and facilitates the seamless coexistence of diverse software versions within the same system environment.

What is ASP.NET membership?

ASP.NET membership gives you a built-in way to validate and store user credentials. With this facility, any user can establish an account with the site, and sign in for exclusive access to the site and its services.

Why to use "runat=server" for HTML element?

The "runat=server" attribute basically tells ASP.Net that it needs to parse the element, its attributes and it's contents as a server control. Some controls have explicit implementations, others simply revert to a generic control implementation.

Differentiate between file-based dependency and key-based dependency

File-based dependency allows you to establish a dependency based on a file stored on a disk. It provides the capability to set dependencies on multiple files, enabling the system to monitor changes in those files. In such cases, the dependency is constructed from an array of files or directories, ensuring that any modifications to these files trigger the appropriate actions.

On the other hand, key-based dependency involves establishing a dependency on another cached item. This approach is particularly beneficial when dealing with multiple interconnected objects in the cache. If any of these objects undergoes a change, it becomes necessary to update or expire all associated items. By relying on key-based dependencies, the system can efficiently manage the synchronization and invalidation of interconnected cached objects.

What is meant by runtime hosts?

The runtime host is responsible for loading the .NET runtime into a process and managing the execution environment. It facilitates the creation of application domains within the process and the loading of user code into these domains. Each type of application, including ASP.NET applications, requires a specific runtime host to initiate its execution.

In the case of ASP.NET, the runtime host is responsible for loading the appropriate runtime capable of handling incoming web requests into the hosting process. Additionally, ASP.NET creates a dedicated application domain for each web application that will run on the web server. This application domain provides isolation and ensures that the web applications can run independently within the same hosting process, enhancing security and stability.

What is the use of @ Output Cache directive in ASP.NET?

Output caching provides the capability to store the rendered HTML output of a web page, allowing subsequent requests for the same page to be served directly from the cache. This caching mechanism can greatly improve performance, particularly for pages that involve complex processing and are resource-intensive. By caching the output, the page can be retrieved and delivered to users without the need to re-run the expensive processing logic. This results in faster response times and reduced server load, enhancing overall application performance.

What is WSDL?

A WSDL is an XML document that describes a web service. It actually stands for Web Services Definition Language. It is a way to describe services and how they should be bound to specific network addresses. It descibes the contract between service & client. WSDL has three parts:

  1. Definitions
  2. Operations
  3. Service bindings

What is a formatter?

A formatter is a critical component in the data transmission process, as it handles the encoding and serialization of data into messages at the sender's end, and the deserialization and decoding of messages into data at the receiver's end. Its primary role is to ensure that the data is properly formatted and packaged for efficient and accurate communication between systems. By utilizing a formatter, data can be seamlessly converted into a format suitable for transmission, allowing for effective intercommunication and interoperability between different components or systems.

Can we add code files of different languages in App_Code folder?

Yes. Create two subfolders inside the App_Code and then add both C# and VB.NET in the respective subfolders. You also have to add a web.config file to your web site and add the following markup to it:

<codeSubDirectories> <add directoryName="MyVBCode"/> <add directoryName="MyCSharpCode"/> </codeSubDirectories >

How does the user code initialize?

User code initialization occurs during the processing stage of a page, typically triggered by the Page.Load event. This event is consistently fired, regardless of whether the page is being requested for the first time or as part of a postback. It provides a reliable entry point for executing custom logic and preparing the page for further processing. By using the Page.Load event, developers can ensure that necessary initialization tasks are performed consistently and reliably, enhancing the overall functionality and behavior of the page.

What is the default authentication mode for IIS?

Anonymous is the default authentication mode for IIS.

Which objects is used to create foreign key between tables?


Can a dll run as stand alone application ?

You can't run dll at all. You can create exe and add your dll as a reference.

What is the extension of a web user control file ?

The file name extension for the user control is .ascx.

What is the use of @ Register directives?

@Register directive provides information to the complier about any custom control added to page.

< %@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>