Introduction to ASP.NET
- ASP.NET provides a true language-neutral execution
framework for Web applications to use. This provides language independence as
long as the language is supported by NGWS framework. This means weather you
use C#, VB, JScript or Perl your code will be converted to Intermediate
Language and then executed by NGWS framework.
- ASP.NET allows true separation of code and content. With
ASP.NET you can place your code and HTML in separate files thus making
- The new ASP.NET server controls provide nice way to
minimize the amount of code you write
- ASP.NET Web Services makes it much easier to tailor your
pages to suit a specific device.
- ASP.NET files are stored with .aspx extension rather
than .asp. Older .asp files are still valid but can not take advantages of new
- ASP.NET server controls are capable of maintaining their
state i.e. programmer need not keep track of values entered by the user in
form controls while redisplaying the same form
- ASP.NET also provides some advanced controls like
datagrid, datalist , repeater and calendar which provide rich functionality
and saves programmer from lot of code.
- All the ASP.NET server controls are compatible with HTML3.2 and above browsers which means
you need not write separate code for different browsers.
ASP.NET and Scripting Languages
- ASP.NET uses compiled languages rather that scripting languages. For
example VB C#, JScript and Perl.
- You can use only one language per page
- If you want mix two languages you have to use
pagelets. Pagelets are miniature ASP.NET pages that can be embedded in other
- Functions must be inside a <SCRIPT> block rather than <% and %> block
Types of ASP.NET controls
- HTML controls : They represent standard HTML controls but run at server end.
- WebControls : ASP.NET offers a set of controls which map closely to
standard HTML controls but provide consistent properties, methods and events. Some
WebControls like data grid provide advance features which are not available with
standard HTML controls
The common HTML controls
The common Web Controls
There are also some advance controls like Input validation controls and data bound grid
which we will see later.
Advantages of Server side Controls
- Your code structure becomes clean and more readable
- Separation of processing code and display code is
- To access the values of the controls you no longer
need to use Request collection, you can refer to the control by its id
- The problem of state maintenance is automatically taken care by ASP.NET
Making control run at server
To process HTML or Web control you need to add runat="server" attribute the
<input type="text" id="text1" runat="server">
<asp:TextBox id="text1" runat="server />
How ASP.NET maintains state?
ASP.NET uses hidden fields to maintain state of your controls. Hidden fields are used to
store values entered by the user into the form controls. There are some points which you
should note about state maintenance :
- Your FORM must run at server i.e. you must set runat
attribute of FORM element to "server"
- You must use POST method. This is because if you use GET the data will be passed as
Server-side Event Processing
Server side controls have events that are processed at server end. Here again you set
the runat attribute of SCRIPT element to "server". The server side events have
different naming convention to separate them from client side events. Each event is of the
form OnServer<event> e.g. OnSeverClick
<SCRIPT language="VB" runat="server">
Sub MyProc(sender as object,evt as EventArgs)
text1.value = "Hello From ASP.NET"
<INPUT type="text" value="" runat="server"
<INPUT type="submit" value="Submit" runat="server"
We saw what ASP.NET is and how it is significantly different than earlier
versions of ASP. The features like web controls, true data type support, full VB
language support, code separation, compiled execution are some of the key
features of ASP.NET. These features make ASP.NET easy to use and more programmer
friendly than ever before.