Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NET Framework:
Introduction :
.NET Framework: It's a Framework (a software program) for developing, Deploying and
running an application. It's free and easily available on internet or you can get this from
computer Magazine.
.NET Framework: It's a Framework (a software program) for developing, Deploying and
running an application. It's free and easily available on internet or you can get this from
computer Magazine CDs.
• The Microsoft .NET Framework is a managed code programming model for building
applications on Windows clients, servers, and mobile or embedded devices. Developers
use .NET to build applications of many types: Web applications, server applications, smart
client applications, console applications, database applications, and more.
(Source MSDN)
Difference between net framework 1.1 framework 2.0 and framework 3.5
You can download the .NET framework 3.5 with Service pack 1 from here
http://msdn.microsoft.com/en-us/netframework/default.aspx
The Common Language Runtime (CLR) is the virtual machine component of Microsoft''s
.NET initiative. It is Microsoft''s implementation of the Common Language Infrastructure
(CLI) standard, which defines an execution environment for program code. The CLR runs a
form of byte code called the Common Intermediate Language (CIL, previously known as
MSIL (Microsoft Intermediate Language)
(source Wikipedia).
Introduction :
CTS (Common Type System) : Common Type System is the part of .NET Framework built in
with CLR which is responsible for defining , managing different language's operation
supported by .NET Framework.
CTS (Common Type System) : Common Type System is the part of .NET Framework built in
with CLR which is responsible for defining , managing different language's operation
supported by .NET Framework.
• The Common Type System (CTS) is a standard that specifies how Type definitions and
specific values of Types are represented in computer memory. It is intended to allow
programs written in different programming languages to easily share information. As used
in programming languages, a Type can be described as a definition of a set of values (for
example, "all integers between 0 and 10"), and the allowable operations on those values
(for example, addition and subtraction).
(Source Wikipedia)
• When compiling to managed code, the compiler translates your source code into
Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that
can be efficiently converted to native code.(Source MSDN)
Common Intermediate Language (CIL, pronounced either "sil" or "kil") (formerly called
Microsoft Intermediate Language or MSIL) is the lowest-level human-readable programming
language in the Common Language Infrastructure and in the .NET Framework. Languages
which target the .NET Framework compile to CIL, which is assembled into bytecode. CIL is
an object-oriented assembly language, and is entirely stack-based. It is executed by a
virtual machine.
CIL was originally known as Microsoft Intermediate Language (MSIL) during the beta
releases of the .NET languages. Due to standardization of C# and the Common Language
Infrastructure, the bytecode is now officially known as CIL. Because of this legacy, CIL is
still frequently referred to as MSIL, especially by long-standing users of the .NET languages.
(source Wikipedia)
HtmlControls In ASP.NET
HtmlControls don't fire Click event on server side. Unlike WebControls, HtmlControls use
OnClick handler on client side. You can access to Click event by using javascript. To handle
click event on server side you need to use ServerClick event with event handler named
OnServerClick.
HtmlInputText control doesn't have Text property. To get string inside Html text box you
need to use Value property.
HtmlGenericControl also doesn't have Text property. To write text inside HtmlGenericControl
you need to use its InnerText property.
Advantages of HtmlControls
* HtmlControls are very useful if you need to translate classic ASP web site to ASP.NET. Just
add runat="server" to needed <input> or <select > tags and you can convert HTML form to
ASP.NET web form fast.
* With HtmlControls you can easily access any html tag on web page. For example, if you
want to change some attribute of <body> tag, just add runat="server" and you can do it
with one line of code like with TextArea in last example.
* If you need to manipulate HTML tags, you will can do it easily with HtmlControls, instead
of working with ASP.NET code inside of <% and %> like in classic ASP before.
* Reset of all input elements on form is very easy to do with HtmlInputReset control.
* Adding meta tags is easy to do with HtmlMeta control. Or, simply add id and
runat="server" to meta tag, like this:
<meta runat="server" name="description" id="MetaDescription">
Then, you can set meta description with line like this:
[ C# ]
MetaDescription.Attributes["content"] = "This is description of my web site.";
[ VB.NET ]
MetaDescription.Attributes("content") = "This is description of my web site."
System.Web.UI.HtmlControls classes
System.Web.UI.HtmlControls namespace contains these classes:
HtmlAnchor HtmlButton
HtmlForm HtmlImage
HtmlContainerControl HtmlControl
HtmlEmptyTagControlBuilder HtmlGenericControl
HtmlHead HtmlHeadBuilder
HtmlInputButton HtmlInputCheckBox
HtmlInputControl HtmlInputFile
HtmlInputHidden HtmlInputImage
HtmlInputPassword HtmlInputRadioButton
HtmlInputReset HtmlInputText
HtmlInputSubmit HtmlLink
HtmlMeta HtmlSelect
HtmlSelectBuilder HtmlTable
HtmlTable.HtmlTableRowControlCollection HtmlTableCell
HtmlTableCellCollection HtmlTableRow
HtmlTableRow.HtmlTableCellControlCollection HtmlTableRowCollection
HtmlTextArea HtmlTitle
HtmlControls endnote
Note that, by default, simple html tags can be anywhere on page, but programmable html
controls must be inside <form> tag. That form tag must have runat="server" attribute. Of
course, all programmable elements must be properly closed and nested.
There is no runat="client" attribute. If you try to write that, you'll get a parser error.
All HtmlControls are inherited from System.Web.UI.HtmlControls.HtmlControl. All html tags
that not exist in HtmlControls namespace can be accessed by using HtmlGenericControl.
Overview
In this section I plan to cover the basics of HTML controls in ASP.NET, this will get you
started with the rich new framework provided with ASP.NET.
Control Classifications
ASP.NET has given the developer the ability to product HTML code from the server side. If
your coming from classic ASP, you are accustomed to intermingling server side code with
HTML. With ASP.NET, the spaghetti code days are over (unless ofcourse you really like it
that way).
Server Controls have been divided into two major types:
• HTML Controls that are found in the System.Web.UI.HtmlControls namespace
• Web Controls that are found in the System.Web.UI.WebControls namespace
Note: Before we get started, let me point out one of the most common errors ‘newbies’
make when using server-side controls. When declaring the ASP.NET control’s tag in your
.aspx page, be sure to include the “runat=server” attribute. This will tell the compiler that
the follow tag is not a normal HTML tag, rather a ASP.NET control.
To demonstrate the power of HTML controls, I am going to jump right in and develop a
HTML table using 100% HTML controls.
The namespace which we will be working with is the System.Web.UI.HtmlControls.
his section covers the syntax used to declaratively set each of the ASP.NET HTML server
controls on a Web Forms page, and includes information about the properties shared among
all HTML server controls.
In this Section
Topic Description
Describes the HtmlAnchor control. The HtmlAnchor control
HtmlAnchor Control allows you to programmatically access the HTML <a> tag on
the server.
Describes the HtmlButtom control. The HtmlButton control
HtmlButton Control allows you to programmatically access the HTML <button> tag
on the server.
Describes the HtmlForm control. The HtmlForm control allows
HtmlForm Control you to programmatically access the HTML <form> tag on the
server.
Describes the HtmlGenericControl control. The
HtmlGenericControl class allows you to programmatically
HtmlGenericControl access HTML server control tags that are not represented by a
specific .NET Framework class, such as <span>, <div>,
<body>, and <font>.
Describes the HtmlImage control. The HtmlImage control
HtmlImage Control allows you to programmatically access the HTML <img> tag on
the server.
Describes the HtmlInputButton control. The HtmlInputButton
control allows you to programmatically access the HTML <input
HtmlInputButton Control
type= button>, <input type= submit>, and <input type=
reset> tags on the server.
Describes the HtmlInputCheckBox control. The
HtmlInputCheckBox
HtmlInputCheckBox control allows you to programmatically
Control
access the HTML <input type= checkbox> tag on the server.
Describes the HtmlInputFile control. The HtmlInputFile control
HtmlInputFile Controlallows you to programmatically access the HTML <input type=
file> tag on the server.
Describes the HtmlInputHidden control. The HtmlInputHidden
HtmlInputHidden Control
control allows you to programmatically access the HTML <input
type=hidden> tag on the server.
Describes the HtmlInputImage control. The HtmlInputImage
HtmlInputImage Control
control allows you to programmatically access the HTML <input
type= image> tag on the server.
Describes the HtmlInputRadioButton control. The
HtmlInputRadioButton
HtmlInputRadioButton control allows you to programmatically
Control
access the HTML <input type= radio> tag on the server.
Describes the HtmlInputText control. The HtmlInputText control
HtmlInputText Controlallows you to programmatically access the HTML <input type=
text> and <input type= password> tags on the server.
Describes the HtmlSelect control. The HtmlSelect control allows
HtmlSelect Control you to programmatically access the HTML <select> tag on the
server.
Describes the HtmlTable control. The HtmlTable control allows
HtmlTable Control you to programmatically access the HTML <table> tag on the
server.
Describes the HtmlTableCell control. The HtmlTableCell control
HtmlTableCell Controlallows you to programmatically access the HTML <td> and
<th> tags on the server.
HtmlTableRow Control Describes the HtmlTableRow control. The HtmlTableRow control
allows you to programmatically access the HTML <tr> tag on
the server.
Describes the HtmlTextArea control. The HtmlTextArea control
HtmlTextArea Controlallows you to programmatically access the HTML <textarea>
tag on the server.
Shared HTML Control
Describes the properties common to all HTML server controls.
Properties
1. HTML CONTROLS/Client Side:- HTML CONTROLS are standard controls and they
are part of HTML language. These are not classes but they are tags and we can only do
client-side programming with them.Client side code is reside at client's browser itself. It is
executed at client side only. User can easily see the code by View - > Source option.
It is generally used in validation form like text field is empty or not, email address validation
etc. It is faster than server side code.
2. HTML SERVER CONTROLS: HTML SERVER CONTROLS are the same as HTML controls but
they have runat=server attribute. With the HTML server controls we can do server-side
programming. This is more beneficial to those people who are migrating from old web
application to .NET applications.
3. WEB CONTROLS: WEB CONTROLS are .NET classes and they have rich set of properties,
methods, and events. They are programmable on client side as well server side. There are
many control that offer same UI(User Interface)but have more features to HTML controls.
For eg. Calendar controls, data grid controls and validation controls and these control
render to client as HTML controls.
Client controls are the HTML controls, find below the difference between them.
Server Controls
Advantages:
1. ASP .NET Server Controls can however detect the target browser's capabilities and
render themselves accordingly. No issues for compatibility issues of Browsers i.e page that
might be used by both HTML 3.2 and HTML 4.0 browsers code to be written by you.
2. Newer set of controls that can be used in the same manner as any HTMl control like
Calender controls. (No need of Activex Control for doing this which would then bring up
issues of Browser compatibility).
3. Processing would be done at the server side. In built functionality to check for few
values(with Validation controls) so no need to choose between scripting language which
would be incompatible with few browsers.
4. ASP .NET Server Controls have an object model different from the traditional HTML and
even provide a set of properties and methods that can change the outlook and behavior of
the controls.
5. ASP .NET Server Controls have higher level of abstraction. An output of an ASP .NET
server control can be the result of many HTML tags that combine together to produce that
control and its events.
Disadvantages:
1. The control of the code is inbuilt with the web server controls so you have no much of
direct control on these controls
2. Migration of ASP to any ASP.NET application is difficult. Its equivalent to rewriting your
new application
Client Controls
Advantages:
1. The HTML Server Controls follow the HTML-centric object model. Model similar to HTML
2. Here the controls can be made to interact with Client side scripting. Processing would be
done at client as well as server depending on your code.
3. Migration of the ASP project thought not very easy can be done by giving each intrinsic
HTML control a runat = server to make it HTML Server side control.
4. The HTML Server Controls have no mechanism of identifying the capabilities of the client
browser accessing the current page.
5. A HTML Server Control has similar abstraction with its corresponding HTML tag and offers
no abstraction.
Disadvantages:
1. You would need to code for the browser compatibility.
HTML Intrinsic Controls
Advantages:
1. Model similar to HTML
2. Here the controls can be made to interact with Client side scripting
Disadvantages:
1. You would need to code for the browser compatibility
In our CSS tutorial you will learn how to use CSS to control the style and layout of multiple
Web pages all at once.
Introduction: CSS is a cross platform solution for the standardization of website formatting
and provides consistent visual appearance throughout the application. It works with the
conjunction of HTML 4 and so supported by all modern browsers.
Creating Style sheets: To include the empty stylesheet follow:
Website - Add New Item, Select StyleSheet, and click OK.
It will create a css class with mentioned name and .css extension.
Rules: Style sheets consist of rules which define the formatting information for the
particular ingredients under the web page. Each rule name has two parts. The portion
before the period indicates the tag to which the rule applies. The portion after the period is
a unique name (called the CSS class name). Rules can be specified in following manner:
1. If standard tag name (body, h1, td etc) is specified without any period then the rules are
applied to all such tags under the web page.
H1
{
font – weight : bold;
}
Constraint will be set to all H1 tag.
2. If only css class name is mentioned (portion after the period) then the rules are
applicable to all the tags with specified class name.
.BoldText
{
font – weight : bold;
}
Constraint will be set to all tags where css class name is specified as “BoldText”.
3. If complete rule name is mentioned (portion at the both side of period) then the rules are
applied to the specified tag with the specified class name.
H1.BoldText
{
font – weight : bold;
}
Constraint will be set to all H1 tags where css class name is specified as “BoldText”.
Applying stylesheet into the web page: Add the <link > tag under the <Head> section and
give reference of the specific stylesheet.
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
Where href attribute is set to the location of the required stylesheet class (.css).
Now the rules, under the stylesheet, can be applied to the web controls by setting CssClass
property:
<asp:Label ID="Label1" runat="server" Text="Hello" CssClass=" BoldText "></asp:Label>
As “BoldText” rule is open for all tags with specified css class name.
CSS Example
body
background-color:#d0e4fe;
h1
color:orange;
text-align:center;
CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The selector is normally the HTML element you want to style.
Each declaration consists of a property and a value.
The property is the style attribute you want to change. Each property has a value.
CSS Example
CSS declarations always ends with a semicolon, and declaration groups are surrounded by
curly brackets:
p {color:red;text-align:center;}
To make the CSS more readable, you can put one declaration on each line, like this:
Example
color:red;
textalign:center;
CSS Comments
Comments are used to explain your code, and may help you when you edit the source code
at a later date. Comments are ignored by browsers.
A CSS comment begins with "/*", and ends with "*/", like this:
/*This is a comment*/
text-align:center;
/*This is another comment*/
color:black;
font-family:arial;
What is ASP.net?
This tutorial written and contributed by Mitchell Harper. Please see footnote for more info.
You've probably heard the word ASP.net fairly often these days, especially on developer
sites and news. This article will explain what the fuss is all about. ASP.NET is not just the
next version of ASP; it is the next era of web development . ASP.NET allows you to use a
full featured programming language such as C# (pronounced C-Sharp) or VB.NET to build
web application easily.
ASP.NET still renders HTML
Unfortunately, the Internet still has bandwidth limitations and not every person is running
the same web browser. These issues make it necessary to stick with HTML as our mark-up
language of choice. This means that web pages won't look quite as amazing as a fully
fledged application running under Windows, but with a bit of skill and creative flair, you can
make some rather amazing web applications with ASP.NET. ASP.NET processes all code on
the server (in a similar way to a normal application). When the ASP.NET code has been
processed, the server returns the resultant HTML to the client. If the client supports
JavaScript, then the server will use it to make the clients browser experience quicker and
easier. Even with HTML being the limiting factor here, ASP.NET still manages to bring true
OOP (Object Oriented Programming) to the Internet.
OOP on the Internet
Object Oriented Programming makes it possible to build extremely large applications, while
still keeping your code clean and structured. Now with ASP.NET, we can do the same on the
web. Traditional ASP uses HTML and VBScript (or Jscript) to process and render pages, but
because VBScript is a scripting language, you were forced to write spaghetti code (VBScript
was entwined in the HTML and ended up rather messy in larger applications). ASP.NET
separates code from display, and you can even have pages with no ASP.NET code in them at
all. By adding references in your HTML (called controls), you can tell ASP.NET that you want
a button here, some text there, and then in your code, you can manipulate what these
controls look like, what they display, how big they are, etc. Controls can do more than just
display information. You can add events to controls, so that when a visitor clicks on a
button, for example, ASP.NET executes a function of your choice.
Web Services
One great feature of ASP.NET is Web Services. Web services mean that you can literally
have several pieces of your application on different servers all around the world, and the
entire application will work perfectly and seamlessly. Web services can even work with
normal .NET Windows applications. For example: A lot of people would like to have a stock
ticker on their web site, but not many people want to manually type in all changes to the
prices. If one company (a stock broker) creates a web service and updates the stock prices
periodically, then all of those people wanting the prices can use this web service to log in,
run a function which grabs the current price for a chosen company, and return it. Web
services can be used for so many things: news, currency exchange, login verification.. the
ways in which they can be used are limited to your imagination!
Great XML Support
ASP.NET makes it simple to use XML for data storage, configuration and manipulation. The
tools which are built into ASP.NET for working with XML are very easy to use. XML is
excellent for storing information that rarely changes, because you can just cache that
information in the computers memory after it has been initially extracted.
Class Library
ASP.NET includes an enormous class library which was built by microsoft. Because this class
library is so large, it encapsulates a a huge number of common functions. For example, if
you wanted to retrieve data from a database and display that data in a simple grid control
through classic ASP, then you'd have to write quite a lot of code.
In ASP.NET, you don't write any code to display the data: you just write the code to bind the
data to an object called a DataGrid (which can be done in just a couple of lines). Then, you
just have to create a reference on your page to where that DataGrid should go. The
DataGrid will be rendered as a table, and will contain all of the data extracted from the
database.
Microsoft has created an amazingly well designed MSDN library for ASP.NET and all of the
other .NET languages. It includes a full class library containing information and examples on
every class, function, method, and property accessible through ASP.NET.
The MSDN library also includes some tutorials and examples to get you started. It may take
you a while to get used to the format and layout of the MSDN ASP.NET library, however,
once you do, you will find it's an invaluable resource to aid you throughout your ASP.NET
learning experience. The .NET MSDN library can be found at
http://msdn.microsoft.com/net/
Complete Compatibility
One of the most important goals of .NET was to allow developers to write an ASP.NET
application using multiple programming languages. As long as each ASP.NET page contains
only one programming language, you can mix and match different pages using different
languages and they will work together seamlessly. This means you can now have a team of
developers with half programming in C#, and the other half in VB.NET, with no need to
worry about language incompatibilities, etc.
A cool little side-affect of all this is that all the programming languages look very similar,
and differ only by their language syntax.
Take the following code snippets for example. They both do exactly the same thing but the
first is written in C#, and the second in VB.NET.
The C# version:
void Page_Load(Object S, EventArgs E) { myLabel.Text = "Hello world!!";
</script>
The VB.NET version:
Sub Page_Load(S As Object, E As EventArgs) myLabel.Text = "Hello world!!"
End Sub
</script>
If you take either of the code examples shown above and add the following HTML to them,
then they would both run perfectly inside of an ASP.NET page:
<head>
<title>"Hello World" example!</title>
</head>
<body>
<asp:Label id="myLabel" runat="server" />
</body>
</html>