Lecture Notes for ASP.Net Student Name: Pan Gao

advertisement
Lecture Notes for ASP.Net
Student Name: Pan Gao
ASP.net is a programming framework that enables the development of
web application and services. Part of the Microsoft.net platform, it is an easy
and scalable way to build and run web applications that can target any
browser or device.
ASP.net is a complete rewrite of classic ASP. ASP.net pages have a
new extension which is “aspx”. It has a large set of new controls, it is an
event driven programming, and it works well with XML.
My topic about ASP.net will be focusing on 11 ASP.net key
elements. They are textbox control, radio button list, checkbox control, from
and buttons, event control, hyperlink control, array, binding, hash table, data
set and database connection and displaying.
The general format for making a text box is “<asp: textbox id =
“box” runat = “server”/>”. The prefix asp: identifies this as a server control
and “text box” identifies the type of control. The “text box” is given an ID
value for reference in a script and the runat = “server” parameter indicated
its accessibility by the script. By default, a text box is a single line entry box.
Multiple line of text are permitted with the text mode = “multiple” setting.
With a specification of Text Mode = “password” the text box echoes entered
characters is bullets.
The general format for defining a radio button list is” <asp:
radiobuttonlist id = “my button” runat = “server”>
<asp: listitem text = “red”>
<asp: listitem text = “blue”>
</asp: radio button list>
The “asp: radio button list “ control creates a group of radio buttons rather
than a single button. “<asp: listitem”> contrls representing a radio button in
the set.
The general format for creating checkbox is “<asp: checkbox id = “My
checkbox” text = “click to submit” >. Autopost back
= “true” on
checkedchanged = “checkedchanged = “checked box”>. The “text” attribute
provides the label for the checkbox. The checkbox itself when clicked can
trigger a submission by setting its autopostback = “true” property and
identifying a subroutine to run. A subroutine also can be identified to run on
the submission by coding the oncheckedchanged event handler.
The general format for creating buttons is”<asp: button id = “button1”
text = “clicked me”, runat = “server” onclick = “submit”>. The text attribute
provides the label for the button. The onclick event handler identifies a
subroutine to run when the button is clicked.
Events in ASP.Net is also very important. An event handler is a
subroutine that executes code for a given event.
ASP.Net Hyperlink control creates a text or graphic link similar to the <a
href>tag. The page to link to is specified by the Navigate URL property. The
Link can either be displayed as text or an image. To display text , set the text
property. To display an image, set the image url property.
An arraylist is created in a script by assigning a new arraylist object to a
reference variable. The arraylist is built within the page_load subroutine the
first time the page is loaded. In order to display the contents of the arraylist,
the arraylist has to bind to a control such as radio button, check box, ect.
A hash table is a storage array of item, each representing a key/value
pair. The Keys are the indexes to their related values, and very quick
searches can be made for values by supplying their look up keys. The
general format for defining hash ttable is “ dim mycountries = new
hashable” If you want to add items to the hash table, use the method called
add().
In order to display the contents of XML in ASP.Net. XML first has to
be loaded into a Dataset. Then Dataset must be bind with other controls in
order to display the contents of the XML.
ASP.Net pages that connect to database must gain access to the system
classes that provide data access functionality. For working with Microsoft
Access and other database the use OLEDB provider, the page must import
the system.data.oledb.namespace by including the following directive at the
top of the page. “<%# Import namespace = “system.data.oledb”%> The
namespace includes three basic classes needed to work with access database:
1. oledbconnection – for connecting to a database
2. oleDbcommand - for issuing sql queries against database table
3. oleDbDatareader – for access to the dataset retrieved from queries
In order to displaying the content of the database after making connection,
the database has to bind to a datalist control in order to be displayed
5 short questions;
1. What is the extension for ASP.Net pages?
Aspx
2. What is Hash Table?
A storage array of items.
3. How to display XML files?
Create a dataset, and load xml files to the data set.
4. What is AutoPostBack ?
AutoPostBack is a property of control, by setting AutoPostBack to
“true”, it can trigger a submission.
5. What is the first step you have to do before you make connection to
database?
Import the namespace.
5 Multiple questions
1. ASP.Net is a complete rewrite of which language? (b)
a. JSP b. ASP c. PHP d. javacript
2. ASP.Net is part of which platform? (d)
a. Sun Micro system. b. IBM c. peoplesoft d. Microsoft.net
3. which one is not part of database connection and retrieve? (d)
a. oledbconnetion
b. oldDbcommand
c. oleDbdatareader
d. Datalist
4. Which data structure has key and values? (a)
a. Hash table
b. Arraylist
c. Tree
d. Radio button
5. Which of the following is not the advantage of ASP.NET? (d)
a. object-oriented environment
b. Faster than Classic asp
c. Easy to build web applications
d. Too expensive
5 True or False questions
1. Asp.net is developed by IBM (false)
2. ASP.net is difficult to use (False)
3. The extension for ASP.net pages is “ axpx” (false)
4. Asp.net supports many languages (True)
5. Asp.net runs on the client side (False)
.
Download