ASP
Presented by Bikash Shrestha
Study Handout.
To look at the working examples you can go to
What is or ASP+?
ASP+ is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications.
It is
Next generation of ASP
New paradigm for server side scripting
Part of new .net framework
Why ?
Easy Programming Model
Avoids spaghetti code
Great pages with far less code than ASP
Easy display data
Easy validating user input
Easy uploading files
Works in all browser ( including Netscape, Opera, AOL, and IE)
Flexible Language Options
ASP support VBScript and Jscript
supports 25 .NET languages
Includes built in support for , C++, C#, and
Rich Class Framework
.NET Framework offers over 4500 classes that encapsulates rich functionality like
XML, data access, file upload,
regular expressions, image generation,
performance monitoring and logging,
transactions, message queuing,
SMTP mail, and more
Improved performance & Scalability
3 to 5 times faster than ASP
Due to dynamic compilation
Rich Output Caching
Eliminates the need to query the database on every request
Improve performance of data-driven pages
Compatibility
Not fully compatible with ASP, however can run side by side with older versions.
Instead of .asp it uses .aspx extensions.
Syntax and Semantics
is fully API-compatible with traditional ASP except for the following
Request()
Request.QueryString()
Request.Form()
returns string for all the above commands where as
ASP returns array of strings
For example to access values of value in address Test.aspx?value=45&value=600
Classic ASP would use this syntax
would use this syntax
pages support only a single language.
page functions must be declared in blocks unlike in ASP.
Page-render functions are not supported in
Page-render in ASP
Here is the time:
Same IN
Sub RenderSomething()
Response.Write(" ")
Response.Write("Here is the time: " & Now)
End Sub
Display Hello World in
Save the file as an Hello.aspx extension
Hello W3Schools!
Limitation of Classic ASP
Code has to be placed where the output apprears
Impossible to separate ASP code from HTML
Eg.
Hello W3Schools!
ASP .NET - Server Controls
The "spaghetti-code" problem solved with server controls.
Server controls are tags that are understood by the server.
Three kinds of server controls:
HTML Server Controls - Traditional HTML tags
Web Server Controls - New ASP .NET tags
Validation Server Controls - For input validation
HTML Server Controls
HTML tags understood by server.
Comparable to JavaScript but run at server
Regular HTML elements are, by default, treated as text.
Add runat="server" to HTML elements to make it programmable and to be run at server.
must be within a tag
id attribute is added to identify the server control
They can be used at a run time.
Example of anchor HTML Server Controls
Example of HTML Server Control
Sub Page_Load
link1.HRef=""
End Sub
Visit W3Schools!
Some objects/controls of HTML Server Control
HTMLButton
HTMLImage 2
HTMLInputbutton
HTMLInputCheckbox
HTMLInputHidden
HTMLInputImage
HTMLInputRadiobutton
HTMLTable
HTMLTextarea
Web Server Controls
These are ASP .NET tags understood by the server
Like HTML Server Controls, they require runat="server" to execute in server.
Like HTML Server Controls, they require id.
Does not map to HTML Elements.
More complex elements than HTML Elements
Some Controls/Objects of Web Server Controls
AdRotator
Calendar
CheckboxList
DropdownList
Hyperlink
Image
Validation Server Controls
Used to validate user-input
If invalid data, display an error message to the user
By default, page validation performed when Button, ImageButton, or LinkButton control is clicked
Prevent validation by changing CausesValidation property to false.
Some Objects of Validation Server Controls
CompareValidator
CustomValidator
RangeValidator
RegularExpressionValidator
RequiredFieldValidator
Validationsummary
ASP .NET - Events
An Event Handler is a subroutine that executes code for a given event.
Two example of event handlers are
The page load event
Page.IsPostBack Property
ASP .NET Web Forms
All server controls must appear within a tag with runat="server" tag.
By default the page is submitted to itself.
If action is set then method=“post “ by default, as in Classic ASP.
An .aspx page can only contain ONE
control!
Data Binding
Data binding is used to fill lists with selectable items from an imported data source, like a database, an XML file, or a script.
Usually uses an imported source.
the data is separated from the HTML
any changes to the items are made in the separate data source.
The following controls support data binding
asp:RadioButtonList
asp:CheckBoxList
asp:DropDownList
asp:Listbox
Data Binding Objects
ArrayList Object
The ArrayList object is a collection of items containing a single data value.
The Hashtable Object
The Hashtable object contains items in key/value pairs.
Cannot sort items.
A Hashtable object may automatically generate the text and values to the following controls:
asp:RadioButtonList
asp:CheckBoxList
asp:DropDownList
asp:Listbox
Other Data Binding Controls
SortedList object
It combines the features of both the ArrayList object and the Hashtable object.
XML Files
We can bind a XML files to get data. Example of XML Data Binding
The Repeater
It is used to display a repeated list of items that are bound to the control.
May be bound to a database table, an XML file, or another list of items.
The DataList
Same as Repeater, except it adds a table around the data items by default. DataList DataList
Database connection
To work with databases we need ADO .NET, which is a part of the .NET Framework and it is used to handle data access.
What is ADO .NET?
It is a part of the .NET Framework
It consists of a set of classes to handle data access
It is entirely based on XML
Unlike ADO, it has no Recordset object
Helpful Hints
Most of my work are from
and
Beginning 1.0 with Visual
published by wrox Programmer to Programmer
ISBN 1-861007-33-7
Also to download the presentation slides and see working examples of , you can check at
True/False
1) support 25 .NET languages including Visual and C++.
2) You can have both (.aspx) and asp (.asp) pages running in the same application.
3) is fully API-compatible with traditional ASP without any exception.
4) In , SortedList object is same as Hashtable object except the former can sort the values.
5) By default, in , the page is submitted to itself.
MCQ
1) Why is better than classic ASP
a. has better control over validating user input.
b. Unlike classic ASP, can support multiple language in a single page
c. avoids spaghetti code
d. Both a and c
e. All of the above
2) Why is different from classic ASP?
a. pages support only a single language.
b. page function must be declared in blocks
c. Page-render functions are not supported.
d. All of the above
3) Which of the controls in support Data Binding?
a. Radio Button
b. Repeater
c. Textbox
d. All of the above
e. None of the above
4) in is
a. Part of the .NET framework
b. Entirely based on XML
c. Unlike ADO, has no Recordset Object
d. All of the above
5) In , which is a Web Server Control
a. AdRotator
b. RegularExpressionValidator
c. CustomValidator
d. HTMLInputHidden
Short Answers
1) What are the three Server Controls used in ?
2) Name any two Event handler used in .
3) In , what is a must to process a form in the server?
4) In , what is Data Binding?
5) Name any three Data Binding objects used in .
Questions with Solution
True/False
6) support 25 .NET languages including Visual and C++. True
7) You can have both (.aspx) and asp (.asp) pages running in the same application.True
8) is fully API-compatible with traditional ASP without any exception. False
9) In , SortedList object is same as Hashtable object except the former can sort the values. True
10) By default, in , the page is submitted to itself. True
MCQ
1) Why is better than classic ASP (d)
f. has better control over validating user input.
g. Unlike classic ASP, can support multiple language in a single page
h. avoids spaghetti code
i. Both a and c
j. All of the above
2) Why is different from classic ASP? (d)
e. pages support only a single language.
f. page function must be declared in blocks
g. Page-render functions are not supported.
h. All of the above
3) Which of the controls in support Data Binding? (b)
f. Radio Button
g. Repeater
h. Textbox
i. All of the above
j. None of the above
4) in is (d)
e. Part of the .NET framework
f. Entirely based on XML
g. Unlike ADO, has no Recordset Object
h. All of the above
5) In , which is a Web Server Control (a)
e. AdRotator
f. RegularExpressionValidator
g. CustomValidator
h. HTMLInputHidden
Short Answers
6) What are the three Server Controls used in ?
a. HTML Server Controls
b. Web Server Controls
c. Validation Server Controls
7) Name any two Event handler used in .
a. The page load event
b. The Page.IsPostBack Property
8) In , what is a must to process a form in the server?
a. The form must have a tag
9) In , what is Data Binding?
Data binding is used to fill lists with selectable items from an imported data source, like a database, an XML file, or a script.
10) Name any three Data Binding objects used in .
a. ArrayList Object
b. Hashtable Object
c. SortedList object
d. XML Files
e. The Repeater
f. The DataList
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.