Tuesday, October 13, 2009

What is a bubbled event in ASP.NET server side controls

Bubbling an Event
The ASP.NET page framework provides a technique called event bubbling that allows a child control to propagate events up its containment hierarchy. Event bubbling enables events to be raised from a more convenient location in the controls hierarchy and allows event handlers to be attached to the original control as well as to the control that exposes the bubbled event.

Event bubbling is used by the data-bound controls (Repeater, DataList, and DataGrid) to expose command events raised by child controls (within item templates) as top-level events. While ASP.NET server controls in the .NET Framework use event bubbling for command events (events whose event data class derives from CommandEventArgs), any event defined on a server control can be bubbled.

Labels:

What is smart navigation in ASP.NET Pages

When a page is requested by an Internet Explorer 5 browser, or later, smart navigation enhances the user's experience of the page by performing the following:
• Eliminating the flash caused by navigation.
• Persisting the scroll position when moving from page to page.

• Persisting element focus between navigations.
• Retaining only the last page state in the browser's history.
• Smart navigation is best used with ASP.NET pages that require frequent postbacks but with visual content that does not change dramatically on return. Consider this carefully when deciding whether to set this property to true.
Set the SmartNavigation attribute to true in the @ Page directive in the .aspx file. When the page is requested, the dynamically generated class sets this property.

Labels:

What are main parts of ASP.NET

• A page and controls framework (Web Forms)
• The ASP.NET compiler
• Security infrastructure
• State-management facilities
• Application configuration

• Health monitoring and performance features
• Debugging support
• An XML Web services framework
• Extensible hosting environment and application life cycle management
• An extensible designer environment

Labels:

What is the difference between code inline and code behind models in Asp.Net

Code-Inline model in Asp.Net
In Code-Inline model the code & event handlers for the controls are located in blocks in the same .aspx file that contains the HTML and controls. Code-Inline model is useful when you want to maintain your code and presentation logic in a single file.

Code-behind model in Asp.Net
ASP.NET also supports another way to factor your code and presentation content, called the code-behind model. When using code-behind, the code for handling events is located in a physically separate file from the page that contains server controls and markup. This clear delineation between code and content is useful when you need to maintain these separately, such as when more than one person is involved in creating the application. It is often common in group projects to have designers working on the UI portions of an application while developers work on the behavior or code. The code-behind model is well-suited to that environment.

Labels:

What are the ways to manage state in Asp.Net application

Ways to manage state in Asp.Net are:
• Using Session and Application objects to cache information.
• Using Memory and Disk Cookies to preserve information.
• Using hidden input fields or the URL -embedded information to pass information from one page to another.

• Using the ViewState property of the page to set and retrieve information stored in a StateBag object.
• Using SQL Server to store state information.

Labels:

Explain the limitation & issues with the Cookies

Limitation & Issues with Cookies
Using cookies gives you excellent state management capabilities, as they are simple to implement, and they help you move resources off the server. Like almost any particular technique, cookies have some limitations.

Some Users Dont Allow Cookies
Some users believe that viruses can be sent in a cookie and will not allow them onto their computers. Although there have never been any documented cases of this happening, and no one could realistically send a virus through a cookie, a lot of users still turn off the ability to accept cookies. When this happens, the user will not be able to use your site if you use cookies for managing state.

Performance Can Deteriorate
Imagine that a user walks through a wizard on your site, as you gather 100 pieces of data from that user over several pages. Each page needs to post gathered data to the server. If you wait until all 100 pieces of data are gathered, you need to store that data somewhere in the meantime. If you keep putting data into a cookie, there is a lot of data being sent back and forth between the browser and the server. This will eat up a lot of bandwidth and could slow your whole site down. Remember, the data has to go both ways for each page the users hit on your site.

Cookies Take Up Memory
Some browsers impose a limit on the size of the cookie data they can accept, or the number of cookies they can accept at one time. In addition, the amount of memory that you may chew up on the users machine may cause their operating system to swap some memory to disk. Under this circumstance, the cookie has slowed down your users machine as well as the server.

Labels:

Explain the Limitations & Issues with Automatic SQL Server State Management

• Although using SQL Server to store your session state relieves you of many difficult development issues, youll still need to consider some important limitations:
• Youre limited to SQL Server.
• This technique can only use SQL Server, no other server database. If you do not have a SQL Server installation available, you will be unable to use this solution.

• Performance may suffer.
• Like any of the state management techniques, using SQL Server to manage your applications state can cause your performance degrade a little. Because it takes a little bit of time to make a connection and read and write state information in the database, theres no avoiding a small bit of overhead.

Labels:

What is the purpose of Server.MapPath method in Asp.Net

In Asp.Net Server.MapPath method maps the specified relative or virtual path to the corresponding physical path on the server. Server.MapPath takes a path as a parameter and returns the physical location on the hard drive.

Syntax
Suppose your Text files are located at D:\project\MyProject\Files\TextFiles

If the root project directory is MyProject and the aspx file is located at root then to get the same path use code

/* physical path of TextFiles */
string TextFilePath=Server.MapPath("Files/TextFiles");

Labels:

What is difference between Response.Redirect and Server.Transfer

Response.Redirect vs Server.Transfer

Server.Transfer or Response.Redirect both are the method of choice for transferring the user from one place in the application to another

Server.Transfer is similar in that it sends the user to another page with a statement such as Server.Transfer("WebForm2.aspx"). However, the statement has a number of distinct advantages and disadvantages.

Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.

But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.

The other side debates that Server.Transfer is not user friendly because the page requested may not be the page that shows in the URL. Response.Redirect is more user-friendly, as the site visitor can bookmark the page that they are redirected to.

Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.

That's not all: The Server.Transfer method also has a second parameter"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the original page TextBox control by referencing Request.Form("TextBox1").

Labels:

Explain the concept of Web Application

An introduction to web applications
A web application consists of a set of web pages that are generated in response to user requests. The Internet has many different types of web applications, such as search engines, online stores, auctions, news sites, discussion groups, games, and so on.
Properties of web applications
• Web applications are a type of client/server application. In that type of application, a user at a client computer accesses an application at a server computer. In a web application, the client and server computers are connected via the Internet or via an intranet (a local area network).
• In a web application, the user works with a web browser at the client computer. The web browser provides the user interface for the application. The most popular web browsers are Microsofts Internet Explorer, .Mozilla Firefox

• The application runs on the server computer under the control of web server software. For ASP.NET web applications, the server must run Microsofts web server, called Internet Information Services, or IIS.
• For most web applications, the server computer also runs a database management system, or DBMS, such as Microsofts SQL Server. The DBMS provides access to information stored in a database. To improve performance on larger applications, the DBMS can be run on a separate server computer.
• The user interface for a web application is implemented as a series of web pages that are displayed in the web browser. Each web page is defined by a web form using HTML, or Hypertext Markup Language, which is a standardized set of markup tags.
• The web browser and web server exchange information using HTTP (Hypertext Transfer Protocol).

Labels:

What is LoginView control in ASP.NET

LoginView Control: This control provides templates in which you can create different content for anonymous and authenticated users. The LoginView control is also role-aware, so you can actually create different templates for authenticated users in different roles.

The control displays one of two templates: the AnonymousTemplate or the LoggedInTemplate. In the templates, you can add markup and controls that display information appropriate for anonymous users and authenticated users, respectively.

The LoginView control also includes events for ViewChanging and ViewChanged, which allow you to write handlers for when the user logs in and changes status.

Labels:

What is the use of PasswordRecovery control in ASP.NET

PasswordRecovery Control: This control provides the user interface and corresponding functionality to help users retrieve or reset their passwords. The control has three views: User- name, Question, and Success. The Username view allows the user to enter the username for which a password has to be retrieved or reset. The Question view prompts the user for the answer to a question that was entered during registration. The Success view displays a success message after the password has been delivered via e-mail.

The options available for password retrieval are determined in part by the Membership provider used to provide membership services. ASP.NET 2.0 includes a provider for Microsoft SQL Server. This support password retrieval and security questions. Other providers, such as a third-party offerings or one you create yourself, might not support all those features. Also, the default the built-in providers to stores password hashes. (Clear text and encrypted text are the other options.) Password hashes cannot be used to determine the original password, so by default the only recovery scheme available is to reset the password and e-mail the new password to the user.

Labels:

What is LoginStatus control in ASP.NET

LoginStatus Control: This control produces a Login or Logout hyperlink based on the login status of the current user: an anonymous user sees a Login link, and an authenticated user sees a Logout link. The actual text for the hyperlink as well as the target of the link is, of course, customizable.

The Logout link can be configured to do one of three things after the user has logged out: refresh the current page, redirect the user to the login page, or redirect the user to some other page.

Labels:

What is ChangePassword control in ASP.NET

The ChangePassword control allows users to change their password. The user must first supply the original password and then create and confirm the new password. If the original password is correct, the user password is changed to the new password. The control also includes support for sending an e-mail message about the new password.

The ChangePassword control includes two templated views that are displayed to the user. The first is the ChangePasswordTemplate, which displays the user interface used to gather the data required to change the user password. The second template is the SuccessTemplate, which defines the user interface that is displayed after a user password has been successfully changed.

The ChangePassword control works with authenticated and non-authenticated users. If a user has not been authenticated, the control prompts the user for a login name. If the user is authenticated, the control populates the text box with the user's login name.

Labels:

What is LoginName control in ASP.NET

LoginName control: This control is a placeholder that displays the username of the user. If the current user is anonymous (that is, not authenticated), this control does not render any output.

The LoginName exposes a FormatString property that you can use to display more than just the username. For example, the FormatString could be set to "Welcome, {0}", which would produce the output "Welcome, John" when John is logged in.

Labels:

What is the use of CreateUserWizard control in ASP.NET

CreateUserWizard Control: This control provides a wizard-style interface for creating a new user in the membership system. The CreateUserWizard is a lot more than a simple form for entering a username and password. It includes field validation for all of its fields, including optional regular expression validation for e-mail addresses. It prompts the user to enter a proposed password twice and confirms that the passwords match.

The CreateUserWizard control can also gather a security question and answer from the user if the underlying membership provider supports security questions. The "Walkthrough" section for this application also shows how you can add custom steps to the wizard to collect additional information from the user during registration.

Labels:

What is the use of Master Pages in ASP.NET

ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.

The ContentPlaceHolder control is where the page specific content will be placed. This master page is a template that will act as the base for all subsequent pages.

A master page is an ASP.NET file with the extension .master (for example, MySite.master) with a predefined layout that can include static text, HTML elements and server controls.

The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages. The @ Master directive can contain most of the same directives that a @ Control directive can contain. For example, the following master-page directive includes the name of a code-behind file, and assigns a class name to the master page.

You define the content for the master page's placeholder controls by creating individual content pages, which are ASP.NET pages (.aspx files and, optionally, codebehind files) that are bound to a specific master page. The binding is established in the content page's @ Page directive by including a MasterPageFile attribute that points to the master page to be used.

Labels:

What are the benefits of new membership features in ASP.NET

The new membership features in ASP.NET 2.0 simplify user management in these ways:
• They automatically create a data store. When you attempt to use membership features, ASP.NET 2.0 checks whether the specified data store is configured. If it is not, ASP.NET creates it.

• They include server controls for creating and validating users and displaying user- specific information and login status. New controls such as the Login, LoginStatus, CreateUserWizard, and ChangePassword controls provide pre-built user-interface building blocks, including functionality for the most common membership-related tasks. These controls are highlighted in the New Web Controls application.
• They provide an application programming interface (API) for programmatically manag- ing users. The Membership API is accessed via the Membership class and includes help- ful methods such as CreateUser, DeleteUser, and ValidateUser.
With ASP.NET 2.0 Membership, you can actually create a Web site with protected pages, automatic redirects to a login page, user creation (registration), and user login without writing any code.

Labels:

What is the use of User Profiles in ASP.NET

The membership features in ASP.NET 2.0 let you collect basic user information that is important for authentication, such as username, password, e-mail address, and a secret question/ answer pair for password retrieval. But often you will need to collect and store additional information, such as first name, last name, Web site or Weblog URL, job title, and possibly much more. The new user profile features in ASP.NET 2.0 give you the ability to define additional pieces of information about a user that your application must store. You simply specify in web.config the pieces of information you require and then populate the corresponding fields in a special Profile object at runtime.

The Profile object that ASP.NET 2.0 generates is specific to your application and contains strongly typed properties that map to the entries in your applications web.config file. The Visual Studio IDE reads these entries at design time and builds a specialized class (inherited from HttpProfileBase) automatically so that your application-specific properties are available in the Intellisense menu and can be verified by the compiler.

Labels:

What is the use of Login control in ASP.NET

Login Security Control: This is a composite control that ties into the ASP.NET membership features. It contains TextBox controls for entering a username and password, as well as a Submit button. This control also includes a number of customizable features, including formatting and all the various pieces of text that can appear, such as instructional text, login failed text, and title text for the control. You can also choose to have the control display hyperlinks to registration and password recovery pages.

The Login control even includes built-in required field validation for both username and password. (Validation can be disabled.) You can write code to support a Login controlin the Authenticate event handler. Even the simplest use of the Login control with absolutely zero code provides a complete working authentication interface.

Labels:

Explain the rich data controls in ASP.Net 2.0.

ASP.NET includes some rich data controls that support repeated-value binding. The rich data controls are designed exclusively for data binding. They also have the ability to display several properties or fields from each data item, often in a table-based layout or according to a template youve defined; they support higher-level features such as editing; and they provide several events that allow you to plug into the controls inner workings at various points.

The rich data controls include the following:
GridView: The GridView is an all-purpose grid control for showing large tables of information. It supports selecting, editing, sorting, and paging. The GridView is the heavyweight of ASP.NET data controls. Its also the successor to the ASP.NET 1.x DataGrid.

DetailsView: The DetailsView is ideal for showing a single record at a time, in a table that has one row per field. The DetailsView supports editing and optional paging controls that allow you to browse through a sequence of records.

FormView: Like the DetailsView, the FormView shows a single record at a time, supports editing, and provides paging controls for moving through a series of records. The difference is that the FormView is based on templates, which allow you to combine fields in a much more flexible layout that doesnt need to be based on a table.

Labels:

What is the use of Tree View Control in ASP.NET 2.0

New site navigation controls in ASP.NET 2.0
Microsoft ASP.NET 2.0 introduces two new site navigation controls, the TreeView and Menucontrols, which can be used to represent hierarchical data. Both controls are feature rich and were designed to work in a wide-variety of scenarios. Both controls can be used to display static data, site-map data, and even database data. In addition, both controls support a rich client-side experience. The TreeView and Menu controls render JavaScript for uplevel browsers, but they are also compatible with downlevel browsers.

Use of TreeView control
You can use the TreeView control in any situation in which you need to display hierarchical data. For example, you can use this control when displaying a navigation menu, displaying database records from database tables in a Master/Detail relation, displaying the contents of an XML document, or displaying files and folders from the file system.

Labels:

What are the new server side controls in Asp.Net 2.0

ASP.NET 2.0 introduces many new server controls that enable powerful declarative support for data access, login security, wizard navigation, menus, treeviews, portals, and more. Many of these controls take advantage of core application services in ASP.NET for scenarios like data access, membership and roles, and personalization. Some of the new families of controls in ASP.NET 2.0 are described below.

Data Controls:
Data access in ASP.NET 2.0 can be accomplished completely declaratively (no code) using the new data-bound and data source controls. There are new data source controls to represent different data backends such as SQL database, business objects, and XML, and there are new data-bound controls for rendering common UI for data, such as gridview, detailsview, and formview..

Navigation Controls:
The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.

Login Controls:
The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.

Web Part Controls:
Web parts are an exciting new family of controls that enable you to add rich, personalized content and layout to your site, as well as the ability to edit that content and layout directly from your application pages. These controls rely on the personalization services in ASP.NET 2.0 to provide a unique experience for each user in your application.

Labels:

What are the new features in ASP.NET 2.0

ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications. The first version of ASP.NET offered several important advantages over previous Web development models. ASP.NET 2.0 improves upon that foundation by adding support for several new and exciting features in the areas of developer productivity, administration and management, extensibility, and performance

New Server Controls:
ASP.NET 2.0 introduces many new server controls that enable powerful declarative support for data access, login security, wizard navigation, menus, treeviews, portals, and more. Many of these controls take advantage of core application services in ASP.NET for scenarios like data access, membership and roles, and personalization.

Master Pages:
This feature provides the ability to define common structure and interface elements for your site, such as a page header, footer, or navigation bar, in a common location called a "master page", to be shared by many pages in your site. In one simple place you can control the look, feel, and much of functionality for an entire Web site. This improves the maintainability of your site and avoids unnecessary duplication of code for shared site structure or behavior.

Themes and Skins:
The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel. You can define style information in a common location called a "theme", and apply that style information globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site and avoid unnecessary duplication of code for shared styles.

Personalization:
Using the new personalization services in ASP.NET 2.0 you can easily create customized experiences within Web applications. The Profile object enables developers to easily build strongly-typed, sticky data stores for user accounts and build highly customized, relationship based experiences. At the same time, a developer can leverage Web Parts and the personalization service to enable Web site visitors to completely control the layout and behavior of the site, with the knowledge that the site is completely customized for them. Personalization scenarios are now easier to build than ever before and require significantly less code and effort to implement.

Localization:
Enabling globalization and localization in Web sites today is difficult, requiring large amounts of custom code and resources. ASP.NET 2.0 and Visual Studio 2005 provide tools and infrastructure to easily build Localizable sites including the ability to auto-detect incoming locale's and display the appropriate locale based UI. Visual Studio 2005 includes built-in tools to dynamically generate resource files and localization references. Together, building localized applications becomes a simple and integrated part of the development experience.

Administration and Management:
New tools like Configuration API, ASP.NET MMC Admin Tool, Pre-compilation Tool, Health Monitoring and Tracing have been introduced.

Performance and Scalability:
ASP.NET is built to perform, using a compiled execution model for handling page requests and running on the world's fastest web server, Internet Information Services. ASP.NET 2.0 also introduces key performance benefits over previous versions like 64-Bit Support and Caching Improvements

Labels: