Anda di halaman 1dari 6

ASP.NET Interview QNS: 1. What is ASP.Net? What are the advantages ASP.Net Technologies? ASP.

Net is a server side Technology to develop a web based applications.ASP.Net will make use of .Net framework features. Advantages of ASP.Net
y y y y

ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model ASP.NET offers built-in security features through windows authentication or other authentication methods. Content and program logic are separated which reduces the inconveniences of program maintenance. Built-in caching features.

2. What are different stages of ASP.Net Page Life cycle? Each ASP.Net Web page performs following stages/events
y y y y y

Page Initialization (Page_Init event) Page Loading (Page_Load event) Page Prerender (Page_Prerender) Page Render (Page_Render) Page Unload (Page_Unload)

3. How do you validate Input data on web page? Before submitting a web page to server, Input validation on web page is one of the important task.ASP.Net provides below validation controls to validate data in web controls and shows user friendly Messages to the user. ASP.Net validation Controls 1. 2. 3. 4. 5. 6. Required field validator control Compare validator control Range Validator Control Regular Expression validator Control Validation Summary Custom validator

4. what are the different state management techniques in ASP.Net? Asp.Net state management can be maintained in two ways as below Client- Side State Management ASP.Net provides following techniques to store state information. This will improve application performance by minimizing server resource utilization 1.View state 2. Hidden Fields

3. Cookies 4. Query Strings

Server Side State Management With respect to Server Side State Management ASP.Net uses Application state and Session state objects to store data or user state.
What are the differences between custom Web control and user control? Custom Web control is a control that inherits from web server control available in ASP.Net. A Custom Web Control could be compiled into separate .dll file. This custom Web control can be shared across all application by installing this dll in to Global Assembly Catch.User Control is a file (.ascx file) that contains a set of ASP.Net controls and code grouped together to provide common functionality across the application. User control can be used on different web pages of the application. Explain ASP.Net Catching? What are different catching mechanisms available in ASP.Net? ASP.Net catching one of the important performance factor for large web applications. ASP.Net Catching stores frequently accessed data in to catch object. There are two different types catching in ASP.Net 1.Application Catching 2.Page Output Catchin Explain the differences between Server-side and Client-side code? A. Server-side code executes on the server. Client-side code executes in the context of the clients' browser What does the "EnableViewState" property do? Why would I want it on or off? A. It allows page objects to save their state in a Base64 encoded string in the page HTML. One should only have it enabled when needed because it adds to the page size and can get fairly large for complex pages with many controls.

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other? A. Server.Transfer transfers excution directly to another page. Response.Redirect sends a response to the client and directs the client (the browser) to load the new page (it causes a roundtrip). If you don't need to execute code on the client, Transfer is more efficient. How can I maintain Session state in a Web Farm or Web Garden? Use a State Server or SQL Server to store the session state.

What base class do all Web Forms inherit from? A. The Page class

Which WebForm Validator control would you use if you needed to make sure the values in two different WebForm controls matched? A. CompareValidator Control

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? A. You must set the DataSource property and call the DataBind method

What is partial classess in .net?


When there is a need to keep the business logic separate from the User Interface or when there is some class which is big enough to have multiple number of developers implement the methods in it, the class can be separated and written in different files as partial class. The keyword partial must appear in each class. //syntax for C# Public partial class MyPartialClass1 { //code } // this code could be in file1 Public partial class MyPartialClass1 { //code } // this code could be in file2 Can you explain what inheritance is and an example of when you might use it? Inheritance is a fundamental feature of an object oriented system and it is simply the ability to inherit data and functionality from a parent object. Rather than developing new objects from scratch, new code can be based on the work of other programmers, adding only new features that are needed.

Whats an assembly? Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly.

Describe the difference between inline and code behind - which is best in a loosely coupled solution? ASP.NET supports two modes of page development: Page logic code that is written inside <script runat=server> blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked "behind" the .aspx file at run time.

Which method do you invoke on the DataAdapter control to load your generated dataset with data? System.Data.Common.DataAdapter.Fill(System.Data.DataSet); If my DataAdapter is sqlDataAdapter and my DataSet is dsUsers then it is called this way: sqlDataAdapter.Fill(dsUsers); How do you turn off cookies for one page in your site? Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the users hard disk when a session ends.

What is Method Overriding? How to override a function in C#? An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method. Use the override modifier to modify a method, a property, an indexer, or an event. You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override.

Diff between data Reader/Data Adapter?

You can use the ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. Using the DataReader can increase application performance and reduce system overhead because only one row at a time is ever in memory. After creating an instance of the Command object, you create a DataReader by calling Command.ExecuteReader to retrieve rows from a data source, as shown in the following example. SqlDataReader myReader = myCommand.ExecuteReader(); You use the Read method of the DataReader object to obtain a row from the results of the query. while (myReader.Read()) Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0), myReader.GetString(1)); myReader.Close(); The DataSet is a memory-resident representation of data that provides a consistent relational programming model regardless of the data source. It can be used with multiple and differing data sources, used with XML data, or used to manage data local to the application. The DataSet represents a complete set of data including related tables, constraints, and relationships among the tables. The methods and objects in a DataSet are consistent with those in the relational database model. The DataSet can also persist and reload its contents as XML and its schema as XML Schema definition language (XSD) schema. The DataAdapter serves as a bridge between a DataSet and a data source for retrieving and saving data. The DataAdapter provides this bridge by mapping Fill, which changes the data in the DataSet to match the data in the data source, and Update, which changes the data in the data source to match the data in the DataSet. If you are connecting to a Microsoft SQL Server database, you can increase overall performance by using the SqlDataAdapter along with its associated SqlCommand and SqlConnection. For other OLE DB-supported databases, use the DataAdapter with its associated OleDbCommand and OleDbConnection objects.

1.Whats the difference between Response.Write() andResponse.Output.Write()? Ans: Response.Output.Write() allows you to write formatted output. 2.What methods are fired during the page load? Ans: Init() - when the page is instantiated Load() - when the page is loaded into server memory PreRender() - the brief moment before the page is displayed to the user as HTML Unload() - when page finishes loading. 3. When during the page processing cycle is ViewState available? Ans: After the Init() and before the Page_Load(), or OnLoad() for a control. 4. What namespace does the Web page belong in the .NET Framework class hierarchy? Ans: System.Web.UI.Page 5. Where do you store the information about the users locale? Ans: System.Web.UI.Page.Culture 6. Whats a bubbled event? Ans: 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. 7. What data types do the RangeValidator control support? Ans. Integer, String, and Date.
Explain the Event Life cycle of ASP.NET 2.0? The events occur in the following sequence. Its best to turn on tracing(<% @Page Trace=true%>) and track the flow of events : PreInit This event represents the entry point of the page life cycle. If you need to change the Master page or theme programmatically, then this would be the event to do so. Dynamic controls are created in this event. Init Each control in the control collection is initialized. Init Complete* - Page is initialized and the process is completed. PreLoad* - This event is called before the loading of the page is completed. Load This event is raised for the Page and then all child controls. The controls properties and view state can be accessed at this stage. This event indicates that the controls have been fully loaded. LoadComplete* - This event signals indicates that the page has been loaded in the memory. It also marks the beginning of the rendering stage. PreRender If you need to make any final updates to the contents of the controls or the page, then use this event. It first fires for the page and then for all the controls. PreRenderComplete* - Is called to explicitly state that the PreRender phase is completed. SaveStateComplete* - In this event, the current state of the control is completely saved to the ViewState.

Unload This event is typically used for closing files and database connections. At times, it is also used for logging some wrap-up tasks.

Data Controls In ASP.NET


y
<asp:SqlDataSource>: This data source control is designed to work with SQL Server, OLE DB, Open DataBase Connectivity (ODBC), and Oracle databases. Using this control, you can also select, update, delete, and insert data using SQL commands. <asp:ObjectDataSource>: N-tier methodology allows you to create web applications that are not only scalable but also easier to maintain. N-tier principle also enables clean separation, thereby allowing you to easily add new functionalities. In an n-tier application, the middle-tier objects may return complex objects that you have to process in your ASP.NET presentation layer. Keeping this requirement in mind, Microsoft has created this new control that allows you to seamlessly integrate the data returned from the middle-layer objects with the ASP.NET presentation layer. <asp:AccessDataSource>: This is very similar to the SqlDataSource control, except for the difference that it is designed to work with Access databases. <asp:XmlDataSource>: Allows you to bind to XML data, which can come from a variety of sources, such as an external XML file, a DataSet object, and so on. Once the XML data is bound to the XmlDataSource control, this control can then act as a source of data for data-bound controls such as TreeView and Menu. <asp:SiteMapDataSource>: Provides a site navigation framework that makes the creation of a site navigation system a breezy experience. Accomplishing this requires the use of a new XML file named web.sitemap that lays out the pages of the site in a hierarchical XML structure. Once you have the site hierarchy in the web.sitemap file, you can then databind the SiteMap DataSource control with the web.sitemap file. Then the contents of the SiteMapDataSource control can be bound to data-aware controls such as TreeView, Menu, and so on. <asp:GridView>: This control is the successor to the DataGrid control that was part of ASP.NET 1.x, and is used to display multiple records in a web page. However, the GridView also enables you to add, update, and delete a record in a database without writing a single line of code. Similarly to the DataGrid control, in a GridView control each column represents a field, while each row represents a record. As you would expect, you can bind a GridView control to a SqlDataSource control, as well as to any data source control as long as that control implements the System.Collections.IEnumerable interface. <asp:DetailsView>: Can be used in conjunction with the GridView control to display a specific record in the data source. <asp:FormView>: Provides a user interface to display and modify the data stored in a database. The FormView control provides different templates, such as ItemTemplate and EditItemTemplate, that you can use to view and modify the database records. <asp:TreeView>: Provides a seamless way to consume information from hierarchical data sources, such as an XML file, and then display that information. You can use the TreeView control to display information from a wide variety of data sources, such as an XML file, a sitemap file, a string, or a database. <asp:Menu>: Like the TreeView control, the Menu control can be used to display hierarchical data. You can use the Menu control to display static data, sitemap data, and database data. The main difference between the two controls is their appearance.

y y

y y

Anda mungkin juga menyukai