Dy, Olivar, Dela Cruz
Dy, Olivar, Dela Cruz
NET
Dy,
Olivar,
Dela Cruz
What is ASP?(Active Server Page)
• Server-side programming technology
• Consist of static HTML interspersed with script
• ASP intrinsic objects (Request, Response, Server, Application, Session)
provide services.
• Commonly uses ADO to interact with databases
• Application and session variables
• Application and session begin/end events
• ASP manages threads, database connections
ASP Successes
• Simple procedural programming model
• Access to COM components
• ActiveX Data Objects (ADO)
• File System Object
• Custom components
• Script-based: no compiling, just edit, save & run
• VBScript, JScript – leverages existing skills
• Support for multiple scripting languages
ASP Challenges
• Coding overhead (too much code)
• Everything requires writing code!
• Code readability (too complex; code and UI intermingled)
• Maintaining page state requires more code
• Reuse is difficult
• Supporting many types of browsers is difficult
• Deployment issues (e.g. DLL locking)
• Session state scalability and availability
• Limited support for caching, tracing, debugging, etc.
• Performance and safety limitations of script
ASP Goal
• Keep the good parts of ASP and improve the rest
• Simplify: less code, easier to create and maintain
• Multiple, compiled languages
• Fast
• Scalable
• Manageable
• Available
• Customizable and extensible
• Secure
• Tool support
How ASP.net Work
• ASP.NET applications are executed via a sequence of HTTP requests
and HTTP responses.
• Client Web browser request ASPX pages.
• IIS passes the request to the ASP.NET engine on the server.
• The Web server executes the ASPX page and produce XHTML + CSS +
JavaScript
• ASP.NET file is returned to the browser as plain HTML
ASP.net Object Model
• User code executes on the web server in page or control event
handlers
• Controls are objects, available in server-side code
• Derived from System.Web.UI.Control
• The web page is an object too
• Derived from System.Web.UI.Page which is a descendant of
System.Web.UI.Control
• A page can have methods, properties, etc.
ASP Code behind Pages
• Two styles of creating ASP.NET pages
• Controls and code in .aspx file
• Controls in .aspx file, code in code-behind page
• Supported in Visual Studio.NET
• Code-behind pages allow you to separate the user interface design
from the code
• Allows programmers and designers to work independently
c1.Text = “Foo”
c2.Rows = 5
Server Controls
• ASP.NET ships with ~50 built-in control
• Organized into logical families
• HTML controls
• Controls / properties map 1:1 with HTML
• Web controls
• Richer functionality
• More consistent object model
HTML Controls
• Work well with existing HTML designers
• Properties map 1:1 with HTML
table.bgcolor ="red"
• Can specify client-side event handlers
• Good when quickly converting existing pages
• Derived from
System.Web.UI.HtmlControls.HtmlControl
• Supported controls have custom class, others derive from
HtmlGenericControl
Supported Controls
• <a> • <input type=submit>
• <textarea> • <td>
• <img> • <input type=button>
• <button> • <th>
• <form> • <input type=reset>
• <input type=text> • <select>
• <table> • <input type=hidden>
• <input type=file>
• <tr>
Web Control
• Web Controls provide extensive properties to control display and
format, e.g.
• Font
• BackColor, ForeColor
• BorderColor, BorderStyle, BorderWidth
• Style, CssClass
• Height, Width
• Visible, Enabled
Types of Web Controls
• Intrinsic controls
• List controls
• Rich controls
• Validation controls
Intrinsic Control
• Correspond to HTML controls
• Supported controls
• <asp:button>
• <asp:radiobutton>
• <asp:imagebutton>
• <asp:image>
• <asp:linkbutton>
• <asp:label>
• <asp:hyperlink>
• <asp:panel>
• <asp:textbox>
• <asp:table>
• <asp:checkbox>
List Control
• Controls that handle repetition
• Supported controls
• <asp:dropdownlist>
• <asp:listbox>
• <asp:radiobuttonlist>
• <asp:checkboxlist>
• <asp:repeater>
• <asp:datalist>
• <asp:datagrid>
Rich Control
• Custom controls with rich functionality
• Supported Controls
• <asp:calendar>
• <asp:adrotator>
• More will be added
• 3rd party controls are coming
• Demo: RichControls1.aspx
Validation Control
• <asp:RequiredFieldValidator>
• Ensures that a value is entered
• <asp:RangeValidator>
• Checks if value is within minimum and maximum values
• <asp:CompareValidator>
• Compares value against constant, another control or data type
• <asp:RegularExpressionValidator>
• Tests if value matches a predefined pattern
• <asp:CustomValidator>
• Lets you create custom client- or server-side validation function
• <asp:ValidationSummary>
• Displays list of validation errors in one place
Validation Control
• Validation controls are derived from
System.Web.UI.WebControls.BaseValidator, which is derived from the
Label control
• Validation controls contain text which is displayed only if validation
fails
• Text property is displayed at control location
• ErrorMessage is displayed in summary
Hello World. asp
Hello World . aspx