


































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



































(Batch 2016-2019)
INDEX
S.NO. NAME OF THE CHAPTER^ PAGE
NO.
REMARK
Introduction to ASP.NET
ASP.Net is a framework which is used to develop a Web-based application. The basic architecture of the ASP.Net framework is as shown below.
The Common Language Infrastructure or CLI is a platform. .Net programs are executed on this platform. The CLR is used for performing key activities. Activities include Exception handling and Garbage collection.
Common Language Infrastructure(CLI) : -
Part of Microsoft's .NET strategy, Common Language Infrastructure (CLI) enables an
application programwritten in any of several commonly-used programming languages to be run
on any operating system using a common runtime program rather than a language-specific one.
Common Language Infrastructure provides a virtual execution environment comparable to the
one provided by Sun Microsystems for Java programs.
The Commerce Server Base Class Library is a collection of classes, interfaces, and value
types that are included in the Commerce Server .NET Application Framework. This library
provides access to run-time Commerce Server functionality and is designed to be the foundation
on which .NET-based Commerce Server applications are built. The Base Class Library exposes
an API that is optimized for the .NET Frameworkwhile using the services provided by the
Common Language Runtime Interop Layer.
ASP.NET Basics
ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required to build up robust web applications for PC, as well as mobile devices.
ASP.NET works on top of the HTTP protocol, and uses the HTTP commands and policies to set a browser-to-server bilateral communication and cooperation.
ASP.NET is a part of Microsoft .Net platform. ASP.NET applications are compiled codes, written using the extensible and reusable components or objects present in .Net framework. These codes can use the entire hierarchy of classes in .Net framework.
The ASP.NET application codes can be written in any of the following languages:
ASP.NET is used to produce interactive, data-driven web applications over the internet. It consists of a large number of controls such as text boxes, buttons, and labels for assembling, configuring, and manipulating code to create HTML pages.
ASP.Net Page Life cycle
When an ASP.Net page is called, it goes through a particular lifecycle. This is done before the
response is sent to the user. There are series of steps which are followed for the processing of an ASP.Net page.
Let's look at the various stages of the lifecycle of an ASP.Net web page.
This is when the page is first requested from the server. When the page is requested, the server checks if it is requested for the first time. If so, then it needs to compile the page, parse the response and send it across to the user. If it is not the first time the page is requested, the cache is checked to see if the page output exists. If so, that response is sent to the user.
During this time, 2 objects, known as the Request and Response object are created. The Request object is used to hold all the information which was sent when the page was requested. The Response object is used to hold the information which is sent back to the user.
PreInit is the first event in page life cycle. It checks the IsPostBack property and determines whether the page is a postback. It sets the themes and master pages, creates dynamic controls, and gets and sets profile property values. This event can be handled by overloading the OnPreInit method or creating a Page_PreInit handler.
Init event initializes the control property and the control tree is built. This event can be
handled by overloading the OnInit method or creating a Page_Init handler.
InitComplete event allows tracking of view state. All the controls turn on view-state
tracking.
LoadViewState event allows loading view state information into the controls.
During this phase, the contents of all the input fields are defined with the tag are
processed.
PreLoad occurs before the post back data is loaded in the controls. This event can be handled by overloading the OnPreLoad method or creating a Page_PreLoad handler.
The Load event is raised for the page first and then recursively for all child controls. The controls in the control tree are created. This event can be handled by overloading the OnLoad method or creating a Page_Load handler.
The loading process is completed, control event handlers are run, and page validation takes
place. This event can be handled by overloading the OnLoadComplete method or creating a Page_LoadComplete handler.
The PreRender event occurs just before the output is rendered. By handling this event,
pages and controls can perform any updates before the output is rendered.
As the PreRender event is recursively fired for all child controls, this event ensures the completion of the pre-rendering phase.
Controls
as literal text and are programmatically inaccessible to page developers. To make these elements programmatically accessible, you can indicate that an HTML element should be parsed and treated as a server control by adding a runat="server" attribute.
The unique id attribute allows you to programmatically reference the control. Attributes are used to declare property arguments and event bindings on server control instances.
HTML server controls must reside within a containing tag with the runat="server" attribute.
HTML Server Controls: Description
HtmlAnchor Controls an HTML element. HtmlButton Controls a HTML element
HtmlForm Controls a HTML element.
HtmlGeneric Controls other HTML elements not specified by a specific HTML server controls, like , , etc. HtmlImage Controls an element
HtmlInputButton Controls ,and Html element. HtmlInputCheckBox Controls an HTML element.
HtmlInputFile Controls an html element.
HtmlInputHidden Controls an html element.
HtmlInputImage Controls an html element.
HtmlInputRadioButton Controls an html element.
HtmlInputText Controls an and html element. HtmlSelect Controls a Html element.
HtmlTable Controls a Html element.
HtmlTableCell Controls a and Html element.
HtmlTableRow Controls a Html element.
HtmlTextArea Controls a Web Server Control Description AdRotator Displays a sequence of images. Button Displays a push button. Calender Displays a calendar. CalendarDay A day in a calendar control. CheckBox Displays a checkbox. CheckBoxList Creates a multi-selection checkbox group. DataGrid Displays fields of data source in grid. DataList Displays items from a data source by using templates. DropDownList Creates a Drop-down List. HyperLink Creates a hyperlink. Image Displays an image. ImageButton Displays a clickable image. Label Display static content which is programmable (lets you apply styles to its content). LinkButton Creates a hyperlink button. ListBox Creates a single or multi-selection drop-down List. ListItem Creates an item in a list. Literal Display static content which is programmable (does not let you apply styles to its content). Panel Provides a container for other controls. PlaceHolder Reserves space for controls added by code. RadioButton Creates a radio-button. RadioButtonList Creates a group of radio-buttons. BulletedList Creates a list in bullet format. Repeater Displays a repeated list of items bound to the control. Style Sets the style of controls. Table Creates a table. TableCell Creates a table cell. TableRow Creates a table row. TextBox Creates a text box. Xml Displays an XML file or the results of an XSL transform.
At times, you might need functionality in a control that is not provided by the built-in ASP.NET Web server controls. In those cases, you can create your own controls. You have two options.
User controls. User controls are containers into which you can put markup and Web server controls. You can then treat the user control as a unit and define properties and methods for it.
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="Defa ult"%> <%@RegisterSrc="~/footer.ascx"TagName="footer"TagPrefix="Tfooter"%>
User Control
When executed, the page shows the footer and this control could be used in all pages of your website.
An important aspect of creating ASP.NET Web pages for user input is to be able to check that the information users enter is valid. ASP.NET provides a set of validation controls that provide an easy-to-use but powerful way to check for errors and, if necessary, display messages to the user. The topics in this section describe the validation controls and how to use them.
Validation Control Description
CompareValidator Compares the value of one input control to the value of another input control CustomValidator Allows you to write a method to handle the validation of the value entered RangeValidator Checks that the user enters a value that falls between two values
RegularExpressionValidator Ensures that the value of an input control matches a specified value
RequiredFieldValidator Makes an input control a required field
ValidationSummary Displays a report of all validation errors occurred in a Web Page.
Custom control is a control that is not included in the .NET framework library and is
instead created by a third-party software vendor or a user. Custom control is a concept used
while building both Windows Forms client and ASP.NET Web applications.
Type: It specifies the data type.
ControlToCompare: It specifies the value of the input control to compare with. ValueToCompare: It specifies the constant value to compare with. Operator: It specifies the comparison operator, the available values are: Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, and DataTypeCheck.
The RegularExpressionValidator control allows validating the input text by matching
against a pattern of a regular expression. The regular expression is set in the ValidationExpression property.
The CustomValidator control allows writing application specific custom validation routines
for both the client side and the server side validation.
The client side validation is accomplished through the ClientValidationFunction property.
The client side validation routine should be written in a scripting language, such as JavaScript or VBScript, which the browser can understand.
The ValidationSummary control does not perform any validation but shows a summary of all errors in the page. The summary displays the values of the ErrorMessage property of all validation controls that failed validation. The following two mutually inclusive properties list out the error message:
ShowSummary: shows the error messages in specified format. ShowMessageBox: shows the error messages in a separate window.
State Management
A new instance of the Web page class is created each time the page is posted to the server. In traditional Web programming, this would typically mean that all information associated with the page and the controls on the page would be lost with each round trip. For example, if a user enters information into a text box, that information would be lost in the round trip from the browser or client device to the server.
To overcome this inherent limitation of traditional Web programming, ASP.NET includes several options that help you preserve data on both a per-page basis and an application-wide basis. These features are as follows: