Session 4: HTML and Web Server Controls - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Session 4: HTML and Web Server Controls

Description:

input type='text' id='txtName' runat='server' / Web Server Controls ... Single file. Understanding How Code-Behind Pages Work ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 12
Provided by: Micro253
Category:

less

Transcript and Presenter's Notes

Title: Session 4: HTML and Web Server Controls


1
Session 4HTML and Web Server Controls
2
Outline
  • Creating Web Forms
  • Using Server Controls
  • HTML Server Controls
  • Web Server Controls
  • Writing ASP Code
  • Inline Code
  • Code behind pages
  • Event Procedures
  • Using Page Events

3
What Is a Web Form?
  • .aspx extension
  • Page attributes
  • _at_ Page directive
  • Body attributes
  • Form attributes
  • lt_at_ Page Language"vb" gt
  • lthtmlgt
  • ltbodygt
  • ltform id"Form1" method"post" runat"server"gt
  • lt/formgt
  • lt/bodygt
  • lt/htmlgt

4
What is a Server Control?
ltaspButton id"Button1" runat"server"
Text"Submit"/gt
  • Runat"server"
  • Events happen on the server
  • View state saved
  • Have built-in functionality
  • Common object model
  • All have Id and Text attributes
  • Create browser-specific HTML

5
Types of Server Controls
  • HTML server controls
  • Web server controls
  • Intrinsic controls
  • Validation controls
  • Rich controls
  • List-bound controls
  • Internet Explorer Web controls

6
HTML Server Controls
  • Based on HTML elements
  • Exist within the System.Web.UI.HtmlControls
    namespace

ltinput type"text" id"txtName" runat"server"
/gt
7
Web Server Controls
  • Exist within the System.Web.UI.WebControls
    namespace
  • Control syntax
  • HTML that is generated by the control

ltaspTextBox id"TextBox1" runat"server"gtText_to_
Display lt/aspTextBoxgt
ltinput name"TextBox1" type"text"
value"Text_to_Display" Id"TextBox1"/gt
8
Selecting the Appropriate Control
Use Web Server Controls if
Use HTML Server Controls if
You prefer a Visual Basic-like programming model
You prefer an HTML-like object model
You are writing a page that might be used by a
variety of browsers
You are working with existing HTML pages and want
to quickly add ASP.NET Web page functionality
You need specific functionality such as a
calendar or ad rotator
The control will interact with client and server
script
Bandwidth is not a problem
Bandwidth is limited
9
Writing ASP.NET Code Inline Code
  • Code and content in the same file
  • Different sections in the file for code and HTML

ltSCRIPT Language"vb" runat"server"gt Sub
btn_Click(s As Object, e As EventArgs) Handles
btn.Click ... End Sub lt/SCRIPTgt ltHTMLgt
ltaspButton id"btn" runat"server"/gt lt/HTMLgt
10
Writing ASP.NET Code Code-Behind Pages
  • Separation of code from content
  • Developers and UI designers can work independently

Separate files
Single file
code
lttagsgt
code
lttagsgt
Form1.aspx.vb or Form1.aspx.cs
Form1.aspx
Form1.aspx
11
Understanding How Code-Behind Pages Work
  • Create separate files for user interface and
    interface logic
  • Use _at_ Page directive to link the two files
  • Pre-compile or JIT-compile

Page1.aspx.cs public class WebForm1
private void cmd1_Click()

Page1.aspx lt _at_ Page Language"c"Inherits"Proje
ct.WebForm1" Codebehind"Page1.aspx.cs" Src
"Page1.aspx.cs" gt
Write a Comment
User Comments (0)
About PowerShow.com