Professional Documents
Culture Documents
<HTML>
<asp:Button id="btn" runat="server"/>
</HTML>
<SCRIPT Language="c#" runat="server">
private void btn_Click(object sender, System.EventArgs
e)
{
. . .
}
</SCRIPT>
What Are Code-Behind Pages?
• Separation of code from content
Developers and UI designers can work independently
code
<tags> code
<tags>
• Pre-compile or JIT-compile
Page1.aspx.cs
Page1.aspx
<% @ Page Language="c#" public class WebForm1
{
Inherits="Project.WebForm1" private void cmd1_Click()
Codebehind="Page1.aspx.cs" {
Src = "Page1.aspx.cs" %> …
}
}
Lesson: Adding Event Procedures to Web Server
Controls
• What Are Event Procedures?
Internet .HTM
Pages
Server-Side Event Procedures
.ASPX
Internet
Pages
Multimedia: Client-Side and Server-Side Events
Creating Event Procedures
End Sub
Page_PreInit
Page_PreInit
Page_Init
Page_Init
Page_PreLoad
Page_PreLoad
Control events Page_Load
Page_Load
Change Events Textbox1_Changed
Textbox1_Changed
Action Events Button1_Click
Button1_Click
Page_Unload
Page_Unload
Page is disposed
Multimedia: The PostBack Process
Demonstration: Handling Events
Handling Page.IsPostback Events
Logon information
Virtual machine 2310C_04
User name Student
Password Pa$$w0rd
Logon Page
Login.aspx
Benefits
Coho Home Page Page Header ASPState
Winery Default.aspx Header.ascx
Menu
Registration Component
Register.aspx Class1.vb or Class1.cs Web.
tempdb
config
XML
Doctors Dentists
Files
Lab Review
Module Review and Takeaways
Review Questions
• What is the advantage of using code-behind pages when
adding functionality to a Web Form?
• How is an event procedure associated with an event of a
server control?
• How is a code-behind page associated with an .aspx page?