



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
t was developed by Microsoft to allow programmers to build dynamic web sites, applications and services. The name stands for Active Server Pages Network Enabled Technologies. ASP.NET (software) Developer(s) Microsoft.
Typology: Lecture notes
1 / 27
This page cannot be seen from the preview
Don't miss anything!
ASP.NET Introduction
ASP Stands for Active Server Pages , which is a powerful tool for making dynamic and interactive web pages. An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are executed on the server. It is a Microsoft technology, that runs on the inbuilt server provided by the Microsoft itself i.e. IIS ( Internet Information Services ).
An ASP file comes with the .asp file extension. ASP.NET works on top of the HTTP protocol,
ASP.NET is a web application framework designed and developed by Microsoft. ASP.NET is open source and a subset of the .NET Framework and successor of the classic ASP( A ctive S erver P ages). With version 1.0 of the .NET Framework, it was first released in January 2002.
ASP.NET is built on the CLR(Common Language Runtime) which allows the programmers to execute its code using any .NET language(C#, VB etc.). It is specially designed to work with HTTP and for web developers to create dynamic web pages, web applications, web sites, and web services as it provides a good integration of HTML, CSS, and JavaScript.
.NET Framework is used to create a variety of applications and services like Console, Web, and Windows, etc. But ASP.NET is only used to create web applications and web services. That’s why we termed ASP.NET as a subset of the .NET Framework.
Benefits of ASP.NET?
There are a lot of reasons which makes the ASP.NET popular among the developers. Some of the reasons are listed below:
Extending .NET Framework: ASP.NET is a subset of .NET Framework as it extends the .NET Framework with some libraries and tools to develop web apps. The thing that it adds to the .NET
Framework is Libraries for common web patterns like MVC , Editor Extensions , the base framework to process the web requests , and web-page templating syntax like Razor , etc.
Performance: It is faster than the other web frameworks available in the market.
Backend Code: With the help of ASP.NET you can write the backend code for data access and any logic in C#.
Dynamic Pages: In ASP.NET, Razor provides the syntax for developing the dynamic web pages with the help of C# and HTML. ASP.NET can be integrated with JS(JavaScript) and it also includes the frameworks like React and Angular for the SPA(Single Page Application.)
Supporting different OS: You can develop and execute ASP.NET apps on Windows, Linux, Docker, and MacOS. The Visual Studio provides the tools to build .NET apps different OS.
ASP.NET BASICS
ASP.NET is an open-source server-side web application framework designed for web development to produce dynamic web pages developed by Microsoft to allow programmers to build dynamic web sites, applications and services.
It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages.
ASP.NET's successor is ASP.NET Core. It is a re-implementation of ASP.NET as a modular web framework, together with other frameworks like Entity Framework. The new framework uses the new open-source .NET Compiler Platform (codename "Roslyn") and is cross platform. ASP.NET MVC, ASP.NET Web API, and ASP.NET Web Pages (a platform using only Razor pages) have merged into a unified MVC 6.
This is also called as Base Class Library and it is common for all types of applications i.e. the way you access the Library Classes and Methods in VB.NET will be the same in C#, and it is common for all other languages in .NET.
The following are different types of applications that can make use of .net class library.
In short, developers just need to import the BCL in their language code and use its predefined methods and properties to implement common and complex functions like reading and writing to file, graphic rendering, database interaction, and XML document manipulation.
3. Common Type System (CTS)
It describes set of data types that can be used in different .Net languages in common. (i.e), CTS ensures that objects written in different .Net languages can interact with each other. For Communicating between programs written in any .NET complaint language, the types have to be compatible on the basic level.
4. Common Language Specification (CLS)
It is a sub set of CTS and it specifies a set of rules that needs to be adhered or satisfied by all language compilers targeting CLR. It helps in cross language inheritance and cross language debugging.
Common language specification Rules:
It describes the minimal and complete set of features to produce code that can be hosted by CLR. It ensures that products of compilers will work properly in .NET environment.
Sample Rules:
ASP.NET Page Structure
An ASP.NET page consists of the following elements:
Directives Code declaration blocks Code render blocks ASP.NET server controls Server-side comments Server-side include directives Literal text and HTML tags
Code Render Blocks
Code render blocks to define inline code or inline expressions that execute when a page is rendered, and you may recognize these blocks from traditional ASP. Code within a code render block is executed immediately as it is encountered, usually when the page is loaded or rendered for the first time, and every time the page is loaded subsequently. Code within a code declaration block, on the other hand, occurring within script tags, is only executed when it is called or triggered by user or page interactions. There are two types of code render blocks: inline code and inline expressions , both of which are typically written within the body of the ASP.NET page. Inline code render blocks execute one or more statements and are placed directly inside a page’s HTML within <% and %> characters.
Inline expression render blocks can be compared to Response.Write() in classic ASP. They start with <%= and end with %>, and are used to display values of the variables and methods on a page.
ASP.NET Server Controls
At the heart of ASP.NET pages lies the server controls , which represent dynamic elements that your users can interact with. There are four basic types of server control: ASP.NET controls, HTML controls, validation controls, and user controls.
All ASP.NET controls must reside within a
HTMLInputText
The control is similar to HTML tag but it works on the server. It collects the information from the user.
The general form of the control is:
<input type=text | password id = "input1" maxlength = "maxnoofchar" size = "width" value = "textboxdata" runat="server" >
HTMLInputCheckBox
It works similar to the HTML checkbox control but executes on the server. The user can select values from the two option either yes or no.
The general form of the control is:
HTMLInputRadioButton
It works similar to the HTML tag. Multiple choice type questions can be created using the HTMLInputRadioButton control.
The general syntax for the control is:
HTMLSelect
User can create a listbox using the HTMLSelect control. When user needs to select an option from the list, the control is used.
The general form of the control is:
<select id="select1" runat="server" Items="optionelements" Multiple SelectedIndex="indexofcur
HTMLTable
The table is created using the
The HtmlInputHidden Class
This class creates an HTML hidden control. You can use an HTML hidden control to hold text that the user doesn't see; this text is sent when the Web page is posted back to the server.
The HtmlInputCheckbox Class
Example Here, we are implementing an HTML server control in the form. // htmlcontrolsexample.aspx
This application contains a code behind file. // htmlcontrolsexample.aspx.cs
Output : When we click the button after entering text, it responses back to client.
Web Server Controls Web server controls provide a higher level of abstraction than HTML server controls because their object model matches closely with the .NET Framework, rather than matching with the requirements of HTML syntax. In the HTML source for your page, Web server controls are represented as XML tags rather than as HTML elements. But remember, the browser receives standard HTML in any case.
Web server controls have a number of advanced features:
Web server controls provide a rich object model that closely matches with the rest of the .NET Framework.
Web server controls have built-in automatic browser detection capabilities. They can render their output HTML correctly for both uplevel and downlevel browsers.
Enabled Indicates whether the Web server control is allowed to receive the focus.
EnableViewState Indicates whether view state is enabled for the Web server control.
Font Specifies a FontInfo object that represents the font properties of a Web server control.
ForeColor Specifies the color of text in the Web server control.
Height Specifies the height of the Web server control.
ID Specifies an identifier for the Web server control.
Parent Represents the parent control of the Web server control.
Style Specifies the collection of CSS properties applied to the Web server control.
TabIndex Specifies the tab order of a Web server control.
ToolTip Specifies the pop-up text displayed by the Web server control when the mouse hovers over it.
Visible Indicates whether the Web server control is visible.
Width Specifies the width of the Web server control.
Common Web Server Controls
The following sections discuss some simple but commonly used controls. These controls have a small number of properties, and they are usually rendered as a single HTML element.
The Label Control
A Label control is used to display read-only information to the user. It is generally used to label other controls and to provide the user with any useful messages or statistics. It exposes its text content through the Text property. This property can be used to manipulate its text programmatically
The TextBox Control
A TextBox control provides an area that the user can use to input text. Thus, this server control can be rendered as three different types of HTML elements— , , and .
The Image Control
The Image Web server control can display images from BMP, JPEG, PNG, and GIF files. The control is rendered as an HTML element on the Web page. Table 3.3 summarizes the important properties of the Image class.
The CheckBox and RadioButton Controls
A CheckBox control allows you to select one or more options from a group of options, and a group of RadioButton controls is used to select one out of several mutually exclusive options. The RadioButton controls that need to be set mutually exclusive should belong to the same group specified by the GroupName property. The check box and radio button Web server controls are rendered as and HTML elements on the Web page.
The RadioButton class inherits from the CheckBox class, and both of them share the same members, except for the GroupName property available in the RadioButton class.
The Button, LinkButton, and ImageButton Controls There are three types of button Web server controls. Each of these controls is different in its appearance and is rendered differently on the Web page:
Button —The Button control displays as a push button on the Web page and is rendered as an HTML element.