ASP NET Programming Notes

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 7

ASP .

NET Programming Notes


Chapter 1
DEFINTION

TERM
Active Server Pages (pg.2)
Server-side include pages (pg.2)
aka User Controls (pg.5)
Web forms (pg.3)
Web services (pg.3)
HTML Template (pg.4)

A page that contains server-side scripting


Contain code and content that is used in several pages
Allows quick develop and process forms on web pages
Contain publicly exposed code, so that they can integrate
with other web applications
Contains design content, layout, and controls.

EXAMPLES
End with file extension .inc or .asp
End in .aspx
End in .asmx

NOTE: Most HTML books refer to controls as tags or elements. Within ASP.NET these are known as HTML controls

Server controls
ASP.NET Form controls
Literal Controls
Object-oriented programming
Object
Properties

Decision Control
Structures
Procedural Code
Module
Class
Instantiation

Similar to HTML controls but processed by the server


Identified by the prefix asp: followed by the name of the
control
Page content that is non assigned to a specific control
Allows you to use objects that can be accessed by other
programs
A set of related methods and properties that are
compartmentalized
Used to set the values of a variable defined within an
object.

<input type=text runat =server/>


<asp:Button id =

Use conditional expressions to determine which block of code to execute.


Name for code statements used when using procedural programming.
Consist of one or more classes
First step to creating an object is to create an object definition, known as a class.
Acts as a template for NEW objects.
Second step to creating an object is initializing and declaring the object from a
class.

Class Definitions
Public
Private
Subclasses
Friend
Inheritance
Inherits
Encapsulation
Abstraction
Polymorphism
Variables (pg.207)
Declaring
Option Explicit

Option Strict
Assignment Operator (=)
Constants (pg.210)

Can interact with other objects outside of its own base class
Can only be called within the base class
Used to create a class that inherits from the base class
Declared procedures and properties that can be called from
anywhere.
Allows you to derive the interface and behaviors from another class
Allows you to derive the interface and behaviors from another .NET class
Inner workings of the object are maintained within the object
Ability to create a concept using code
Ability to create code that can be applied to objects that are derived from different
classes
Used to store data than can be retrieved at another time
Process of reserving memory space for the variable before it is used in the program
Forces a program or page to declare 1. <%@Page Option Explicit = true %>
all variables before they can be used 2. For HTML use; put in top of page
3. Can also be place in Web.config makes
all pages inherit this property
Halts any conversion that would
1. <%@ option strict %>
result in data loss
Assigns a value to a variable
Use Const instead of Dim for values that will NOT change, names are all

Concatenation (pg.211)
Reference Types (pg.211)
Value Types (pg.211)
Garbage collector (pg.212)
Property (page214)
Collection
Request Object (pg.13)
User agent (pg.14)
Query String (pg.14)
Response Object (pg.16)
Write Method (pg.16)
WriteFile Method (pg.16)
Caching (pg.16)
Redirecting (pg.16)
Localhost (pg.17)
Scraping (pg17)
UDDI (pg.18)
Namespace

uppercase.
Joining together of two or more string values
Strings, classes, arrays, collections, and objects, stored in managed heaps,
because the amount of memory required for storage varies
Boolean, Integar, Decimal, Char, and DateTime, data is stored in the stack,
because the amount of memory required for storage is constant.
Part of the Common Language Runtime that allocates and manages memory for
the managed heap.
Used to get and set values.
A container to store variables
Used to get information from the
server, but sends info to the server
about the user & browser
Used to identify client software; also
sends certificate information
Containing name & topic
Used to send info to the browser
Allows you to send a string to the
browser
Allows you to send entire contents
of a text file to the web page.
Process where a page is generated
and stored on a server
Redirects client to another page
Mapped root website default
directory C:\Inetpub\wwwroot
Using a program to view a Website
and capture its source code.
Public registry that contains
registered public web services
A hierarchical way to identify
resources

Response.write(Request.PhysicalPath)

http://www.tarastore.com/index.asp?name=katie&topic=asp
Response.Write(Copyright by TaraStore<br/>)
Response.WriteFile(c:\copyright.txt)

Response.Redirect(http:/www.course.com/)
http://localhost/

www.microsoft.com/uddi
1. All objects must inherit system.object.objectname
2. ASP.NET apps must inherit the System.Web Namespace
3. All webforms must inherit System.Web.UI namespace
4. Webservices must inherit System.Web.WebService
5. System.Web.UI.StateBag

StateBag webspace - To store info in


hidden fields
Server Controls
6. Must inherit the appropriate Server control namespace.
Importing a namespace
<%@ Imports NamespaceName %> <% Imports System.Web.UI.Page %> inherits page class
Import user defined namespace in
<@ Import NamespaceName = MyNamespaceName %>
code behind the page
Garbage Collection (pg.26)
Process of allocating and managing
reserved memory.
Managed Heap (pg.26)
Reserved address space in memory
that can be subdivided into and
allocated in smaller pieces.
Compaction
Starting from the root, removal of
objects from the heap that are no
longer referenced by the application.
Chapter 2
Style sheets (pg.61)
describe how documents are presented on
http://www.w3.org/Style/
screens, in print, or perhaps how they are
pronounced.
Cascading Style Sheets (CSS) (pg.60)
Used to separate page content from
presentation
Style rule (pg.60)
Information that is applied to a single
HTML tag
In-line style sheets, aka Internal Style
Formats a single HTML tag.
sheets (pg. 60)
Embedded style sheets (pg.61)
Placed in the heading, can be applied to
ElementName {

one or more tags within a page.

PropertyName: value;
PropertyName: value;
}

External style sheets (pg.62)


rel (pg.62)
Type (pg.62)
href (pg.62)
// (pg. 63)
/* (pg.63)

Cascading Rules (pg63)

Class (pg63)
OnServerChange event (pg.88)

OnServerClick event (pg.88)

Function (pg.89)
_EVENTTARGET and _EVENTARGUMENT
(pg.89))

HTML Server Control event


Table
tr
td

XML Files
XSLT Files

Contain style rules that can be used by


many files at the same time.
Indicates the linked document contains a
style sheet
Used to indicate MIME linked files
Indicates the location of an external style
sheet
Used to add in-line comments
Used to add multi-line comments

In-line style rules take precedence over


embedded style rules, and embedded style
rules take precedence over external style
rules.
Used to format a group of different tags
Occurs when an HTML Server control
value has changed.
(*Help) Mshelp://MS.VSCC/MS.MSDNVS/cpref/_
html/frlrfsystemWebuihtmlcontrolshtml_
imageclasstopic.htm
Occurs when the visitor clicks an HTML
server control.
(*Tutorial) mshelp://MS.VSCC/MS.MSDNVS/_
csref/html/vcwklEventsTutorial.htm
A named grouping of one or more
programming statements.
Used to determine which control called the
function and what parameters were passed
with the control
Event is processed by the server event
handler, and NOT by the client event
handler.
Makes a table
Tag for a new row
Cell in a new row

Chapter 4 (pg135)
There are NO class files associated
with XLM
There are NO class files associated
with XSLT
Chapter 5 (pg.197)

Jumping Structures (Classroom


Materials)

Sub-Routines

---------------------------------------H1{
Color:green
Size:12
}
File extensions end in .css
<link rel=
Href=http://www.website.com
H1 {color:green} //Green
/* This is a
multi-line
comment
/*
1. In-line style rules
2. embedded style rules
3. external style rules
1.
2.
3.
4.
5.
6.

HTMLInputCheckBox
HTMLInputRadio
HTMLInputHidden
HTMLInputText
HTMLTextArea
HTMLSelect

1.
2.
3.
4.

HTMLInputImage
HTMLAnchor
HTMLButton
HTMLForm

<table> </table>
<tr> </tr>
<td> </td>

Functions

Function FunctionName As
Parameter
FunctionCode
End Funtion

Unstructured Error Handling


(Classroom Materials)

Subroutine ()
On Error Resume Next
End Sub
Structured Error Handling
(Classroom Materials)

Can be set to write error events to


the Widows Event Log using the
System.Diagnostic Namespace
Can be set to send an email, using
the MailMessage class in the
System.Web.Mail Namespace
Data Validation (Classroom Materials)

Called validation controls


Prevents users from entering
invalid data that could cause an
exception error during runtime

ArrayList (pg.216)
()
xsl:attribute
xsl:text
xsl:choose
xsl:when
xsl:otherwise
xsl:sort
xsl:if
xsl:if-else-end
XML Schema
TargetSchema
AdRotator
AdScheduler
Ad tag
Impressions property
Root node
Calendar Control
ChrW(60)
ChrW(62)
File Field Control

A series of related data items.


Used to pass and argument to a function
Public Function GetStoreName() AS Integer
XSLT Style Sheets
Specifies attributes for any HTML properties in a template
Used to write out the value of text
Used to analyze the value of a rating
Used if the condition listed in the test attribute is met
Used to format any data that may NOT apply to the other choices listed
Used to sort data
Does NOT run unless the conditional statement resolves to TRUE
Set of rules, or namespace. Ways to structure elements.
Property used to identify the schema being used
Displays a banner ad on a web page, when you refresh the page the ad is
changed
XML document that stores the ad information
Element that contains the individual properties for the ad.
Indicates the frequency with which the banner ad is displayed
Root tag in an XML document
Insert and configure an interactive calendar within a webpage
Inserts the opening brackets < using visual basic .NET
Inserts the ending brackets > using visual basic .NET
Allows you to browse your network and locate a file

CLASSES (Classroom Materials)


Relational Data Namespaces

Contained in System.Data.dll

System

.
.
.
.
.
.

.
.
.
.
.
.

Data

XML Data Namespaces


System
.

System

System
System

.
.
.
.
.
.
.
.

Common
OleDb
SqlClient
SqlTypes

Contained in System.XML.dll

XML

Collections

.
.
.
.
.
.
.
.
.

Schema
Serialization
Xpath
Xsl

ArrayList

HashTable

SortedList

Queue

Stack

.
.
.
.
.

.
.
.
.
.

.
.

Array
Web

.
.
.

UI

can find an element without rotating


through all the elements
can find an element without rotating
through all the elements
can find an element without rotating
through all the elements
needs to rotate through all the elements to
find a single element
needs to rotate through all the elements to
find a single element
Arrays are zero-based

WebControls
HTMLInput
Control

.
.
.

AdRotator
Calendar

.
.
.

There are three basic Coding Techniques


1. <Script> Tags Best method
2. in-line code block allows you to control execution of code
3. server controls

Four Main HTML Server controls


1. HTMLImage control used to represent simple images and returns an image tag.
2. HTMLContainer control represents tags that can contain other elements and must have closing tags.
3. HTMLGeneric control used for other HTML elements not listed in the HTML controls.
4. HTMLInput control retrieves information from the user.

NOTES:
1.
2.
3.
4.
5.
6.

Whatever code you use must inherit from the appropriate namespace
You can import from more than one namespace without causing errors or diminished performance.
Line used to compile code: vbc filename.vb and press enter
* - take the dash out of the path
Webpages contain two hidden fields named _EVENTTARGET and _EVENTARGUMENT
IL DASM stands for Intermediate Language Disassember

Acronyms:
1. ASP Active server pages
2. CLR Common language runtime
3. BCL Base class libraries
4. GC Garbage Collection
5. HTML Hypertext Markup Language
6. DHTML Dynamic HTML combination of JavaScript & cascading style sheets
7. XHTML Extensible Hypertext Markup Language
8. br line break
9. hr horizontal rule
10. UC User Controls
11. ADO Active X Data Objects (Suitable for constant connection between client and server)
12. DAO Data Access Objects (MS Client Server applications, before the internet)
13. RDO Remote Data Objects (Suitable for constant connection between client and server)
14. .xsd XML schema document

Troubleshooting:
1.
I get the following error when trying to create an ASP.net project in VS 2003 Enterprise under Win XP: "Visual Studio .NET
has detected that the specified Web server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web
applications or services." I have tried the following to resolve the problem:
For the schools software it will be regsvr32 C:\Windows\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll

Sources:
Classroom Materials, Unit 4 & 5, (n.d.), taken from http://mycampus.aiu-online.com/classroom/classmaterials.asp?courseid=121&classid=40459&tid=37&LetterCode=
, on Tuesday, April 06, 2004
Daniel L. McGrew, (n.d.), Personal Experience
Kathleen Kalata, (2003), Introduction to ASP.NET, Canada

You might also like