Basics of ASP'NET - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Basics of ASP'NET

Description:

It requires Handles clauses for pages events such as Load and Init. ... html xmlns='http://www.w3.org/1999/xhtml' head runat='server' title Index Page /title ... – PowerPoint PPT presentation

Number of Views:50
Avg rating:3.0/5.0
Slides: 20
Provided by: saxserv
Category:
Tags: asp | net | basics | xhtml

less

Transcript and Presenter's Notes

Title: Basics of ASP'NET


1
Basics of ASP.NET
2
Outline
  • Introduction
  • HTML Form Controls
  • ASP.NET Web Controls
  • Procedures and Functions
  • Page Events

3
Default.html
  • lthtml xmlns"http//www.w3.org/1999/xhtml" gt
  • ltheadgt
  • lttitlegtIndex Pagelt/titlegt
  • lt/headgt
  • ltbodygt
  • ltform id"form1 Actioncgi" Methodget gt
  • Enter name
  • ltinput typetext nametextbox1 /gt
  • ltinput type"submit" value"Submit" /gt
  • ltinput typereset valueClear /gt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

4
Default.aspx
  • lt_at_ Page Language"VB" AutoEventWireup"false"
    CodeFile"Default.aspx.vb" Inherits"_Default" gt
  • lthtml xmlns"http//www.w3.org/1999/xhtml" gt
  • lthead runat"server"gt
  • lttitlegtIndex Pagelt/titlegt
  • lt/headgt
  • ltbodygt
  • ltform id"form1" runat"server"gt
  • ltdivgt
  • ltaspLabel ID"Label1" runat"server"
    Text"Enter Name"gtlt/aspLabelgt
  • ltaspTextBox ID"TextBox1" runat"server"
    gtlt/aspTextBoxgt
  • ltaspButton ID"Button1" runat"server"
    Text"Submit" /gt
  • lt/divgt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

5
Default.aspx.vb
  • Partial Class _Default Inherits
    System.Web.UI.Page
  • Protected Sub Button1_Click(ByVal sender As
    Object, ByVal e As System.EventArgs) Handles
    Button1.Click
  • TextBox1.Text "Here is some sample
    text."
  • End Sub
  • End Class

6
Our First ASP.NET Program
  • The _at_Page directive allows you to set the default
    properties for the entire page such as the
    default language
  • It specifies language
  • AutoEventWireup set to False
  • It requires Handles clauses for pages events such
    as Load and Init.
  • CodeFile the name of the code-behind file
  • Inherits the name of the compiled class the page
    inherits

7
HTML Controls
  • HTML controls are universal
  • Other types of server controls (e.g. ASP.NET
    controls) have to be converted into HTML before
    they can be displayed on the web browser
  • HTML controls lack functions compared to controls
    from other proprietary development tools
  • Form control is the essential way for HTML to
    interact with users

8
ASP.NET Server Controls
  • Two required attributes
  • Runatserver
  • ID
  • ASP.NET code is never sent to the browser
  • All ASP.NET server controls will be converted
    into HTML format before they are sent to the
    browser
  • They provide a consistent object model and
    corresponding events and properties.

9
ltasplabelgt
  • Purpose displaying text
  • Attributes
  • Text
  • BackColor
  • ForeColor

10
ltasptextboxgt
  • Purpose user input
  • Attributes
  • textmode one line (default), multiline, or
    passwrod
  • rows number of rows if textmode is set to
    multiline
  • columns number of columns if textmode is set to
    multiline

11
ltaspradiobuttonlistgt
  • Choice of one option excludes selecting other
    options
  • Example
  • ltaspradiobuttonlist id"fare" runat"server"gt
  • ltasplistitem id"op1" runat"server"
    value"First class" /gt
  • ltasplistitem id"op2" runat"server"
    value"Coach" /gt
  • lt/aspradiobuttonlistgtltbr /gt
  • fairclass fare.SelectedItem.value

12
ltaspdropdownlistgt
  • Selection from a list
  • Example
  • ltaspdropdownlist id"list1" runat"server"gt
  • ltasplistitemgtMadridlt/asplistitemgt
  • ltasplistitemgtOslolt/asplistitemgt
  • ltasplistitemgtLisbonlt/asplistitemgt
  • lt/aspdropdownlistgt

13
ltaspbuttongt
  • Example
  • ltaspButton ID"Button1" runat"server"
    Text"Submit" /gt

14
Procedures
  • Subroutines or sub-procedures do not return
    values and cannot be used in an expression value
  • Create a Subroutine
  • Declared using the keyword Sub
  • Exit sub statement to exit the subroutine
  • End with the keywords End Sub

15
Event Procedure
  • An event procedure is not executed until an event
    triggers the event procedure
  • An event procedure does not return a value
  • The Page_Load event procedure is triggered when
    the page is loaded into the browser

16
Page Events
  • The Page object consists of a variety of methods,
    functions, and properties that can be accessed
    within the code behind the page
  • The first time a page is requested by a client, a
    series of page events occurs
  • The first page event is the Page_Init event which
    initializes the page control hierarchy
  • The Page_Load event loads any server controls
    into memory and occurs every time the page is
    executed

17
simple.aspx
  • lt_at_ Page Language"VB" AutoEventWireup"false"
    CodeFile"simple.aspx.vb" Inherits"simple" gt
  • lthtml xmlns"http//www.w3.org/1999/xhtml" gt
  • lthead runat"server"gt
  • lttitlegtUntitled Pagelt/titlegt
  • lt/headgt
  • ltbodygt
  • ltform id"form1" runat"server"gt
  • ltdivgt
  • lt/divgt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

18
simple.aspx.vb
  • Partial Class simple Inherits System.Web.UI.Page
  • Protected Sub Page_Load(ByVal sender As
    Object, ByVal e As System.EventArgs) Handles
    Me.Load
  • Response.Write("This is my first line of
    ASP.NET program. ltbrgt")
  • Response.Write("More to come next week.
    ltbrgt")
  • End Sub
  • End Class

19
More on Class
  • Class is a blueprint for which objects are
    created
  • Class inheritance
  • It allows one class to acquire all the properties
    and methods of the parent class
  • Partial class
  • It allows you to split a single class into more
    than one file
Write a Comment
User Comments (0)
About PowerShow.com