SlideShare a Scribd company logo
1 of 10
Writing Code
 Writing code in an ASP.NET Web form is done in three
ways:
 Mixed code method
 The code is in the same file as the web content, mixed with the
HTML code
 This method is not recommended as the source code is hard
to read and maintain
 Inline code method
 Code-behind method
2
Writing Code (2)
 Writing code in an ASP.NET web form is done in three
ways:
 Mixed code method
 Inline code method
 The code is separated in a SCRIPT section in the same file
 Code-behind method
3
Writing Code (3)
 Writing code in an ASP.NET web form is done in three
ways:
 Mixed code method
 Inline code method
 Code-behind method
 The code is in the code-behind page – a separate file from the
HTML content
 When using Visual Studio .NET this is the default method
4
Example: Inline Code Method
5
<html>
<asp:Button id="btn" runat="server"/>
...
</html>
<script Language="c#" runat="server">
private void btn_Click(object sender,
System.EventArgs e)
{
...
}
</script>
Code-behind Model
 A separate compiled file containing the program logic of
the page
 Each web page has its own code-behind page
 Has the same name as the web page to which it is attached
 The file extension is .aspx.cs
 The two files are built into one when the application is
started
7
How Does Code-behind Work?
 To associate an .aspx page to its code-behind class the
@Page directive is used
 VS.NET adds three attributes to the @Page directive:
 Inherits – allows the .aspx page to derive from the
code-behind class
 Codebehind – used internally by Visual Studio .NET to
associate the files
 Src – contains the name of the code-behind page
 Used if the application is not precompiled
8
JIT Compilation
 The Code-behind page can be either precompiled or just-
in-time (JIT) Compiled
 JIT compilation
 A compilation at first request
 Set by the Src attribute of the @Page directive
 VS.NET doesn’t add it by default
9
Precompilation
 Precompilation
 Avoids the delay at first request
 Simplifies the deployment of the web application
 The source code of the code-behind class is not
necessary
10

More Related Content

What's hot

Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
Iblesoft
 
Public Library
Public LibraryPublic Library
Public Library
eclumson
 
Asp net mvc
Asp net mvcAsp net mvc
Asp net mvc
bgrynko
 

What's hot (20)

ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
 
Asp.netrole
Asp.netroleAsp.netrole
Asp.netrole
 
Asp.net
Asp.netAsp.net
Asp.net
 
ASP Dot Net Software Development in India - iFour Technolab
ASP Dot Net Software Development in India - iFour TechnolabASP Dot Net Software Development in India - iFour Technolab
ASP Dot Net Software Development in India - iFour Technolab
 
Inventory management project based on ASP.NET, introduction to C# and ASP.NET
Inventory management project based on ASP.NET, introduction to C# and ASP.NETInventory management project based on ASP.NET, introduction to C# and ASP.NET
Inventory management project based on ASP.NET, introduction to C# and ASP.NET
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
 
Microsoft .NET Development Platform Internationalization
Microsoft .NET Development Platform InternationalizationMicrosoft .NET Development Platform Internationalization
Microsoft .NET Development Platform Internationalization
 
2310 b 01
2310 b 012310 b 01
2310 b 01
 
REPORT ON ASP.NET
REPORT ON ASP.NETREPORT ON ASP.NET
REPORT ON ASP.NET
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 
Public Library
Public LibraryPublic Library
Public Library
 
Asp notes
Asp notesAsp notes
Asp notes
 
Empowerment Technologies Lecture 11 (Philippines SHS)
Empowerment Technologies Lecture 11 (Philippines SHS)Empowerment Technologies Lecture 11 (Philippines SHS)
Empowerment Technologies Lecture 11 (Philippines SHS)
 
Intro To Asp Net And Web Forms
Intro To Asp Net And Web FormsIntro To Asp Net And Web Forms
Intro To Asp Net And Web Forms
 
Asp net
Asp netAsp net
Asp net
 
Asp net mvc
Asp net mvcAsp net mvc
Asp net mvc
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentation
 
Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9
 
Facebook APIs
Facebook APIsFacebook APIs
Facebook APIs
 
Membangun Desktop App
Membangun Desktop AppMembangun Desktop App
Membangun Desktop App
 

Viewers also liked (7)

Paula Elvira Espinosa
Paula Elvira EspinosaPaula Elvira Espinosa
Paula Elvira Espinosa
 
La utilización del correo electrónico en la escuela
La utilización del correo electrónico en la escuelaLa utilización del correo electrónico en la escuela
La utilización del correo electrónico en la escuela
 
Las nuevas-tecnologias
Las nuevas-tecnologiasLas nuevas-tecnologias
Las nuevas-tecnologias
 
Ejemplos de herramientas case más utilizadas
Ejemplos de herramientas case más utilizadasEjemplos de herramientas case más utilizadas
Ejemplos de herramientas case más utilizadas
 
El oficio de enseñar Condiciones y Contextos. Capitulo 5 Edith Litwin
El oficio de enseñar Condiciones y Contextos. Capitulo 5 Edith LitwinEl oficio de enseñar Condiciones y Contextos. Capitulo 5 Edith Litwin
El oficio de enseñar Condiciones y Contextos. Capitulo 5 Edith Litwin
 
Tecnología educativa
Tecnología educativaTecnología educativa
Tecnología educativa
 
Tecnologia Educativa
Tecnologia EducativaTecnologia Educativa
Tecnologia Educativa
 

Similar to Code model

Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
sasidhar
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
Mani Chaubey
 
Web matrix part 2
Web matrix part 2Web matrix part 2
Web matrix part 2
yuvaraj72
 

Similar to Code model (20)

01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Chapter 1 (asp.net over view)
Chapter 1 (asp.net over view)Chapter 1 (asp.net over view)
Chapter 1 (asp.net over view)
 
As pnet
As pnetAs pnet
As pnet
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
 
Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handson
 
Asp.net
Asp.netAsp.net
Asp.net
 
A comprehensive software infrastructure of .Net
A comprehensive software infrastructure of .Net  A comprehensive software infrastructure of .Net
A comprehensive software infrastructure of .Net
 
Asp.net c# MVC-5 Training-Day-2 of Day-9
Asp.net c# MVC-5 Training-Day-2 of Day-9Asp.net c# MVC-5 Training-Day-2 of Day-9
Asp.net c# MVC-5 Training-Day-2 of Day-9
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Top 15-asp-dot-net-interview-questions-and-answers
Top 15-asp-dot-net-interview-questions-and-answersTop 15-asp-dot-net-interview-questions-and-answers
Top 15-asp-dot-net-interview-questions-and-answers
 
Top 15 asp dot net interview questions and answers
Top 15 asp dot net interview questions and answersTop 15 asp dot net interview questions and answers
Top 15 asp dot net interview questions and answers
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
 
Asp.net
Asp.netAsp.net
Asp.net
 
Web matrix part 2
Web matrix part 2Web matrix part 2
Web matrix part 2
 
ASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOMASP, ASP.NET, JSP, COM/DCOM
ASP, ASP.NET, JSP, COM/DCOM
 
Introduction to asp
Introduction to aspIntroduction to asp
Introduction to asp
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVC
 
ASP.NET - Web Programming
ASP.NET - Web ProgrammingASP.NET - Web Programming
ASP.NET - Web Programming
 

More from teach4uin (20)

Controls
ControlsControls
Controls
 
validation
validationvalidation
validation
 
validation
validationvalidation
validation
 
Master pages
Master pagesMaster pages
Master pages
 
.Net framework
.Net framework.Net framework
.Net framework
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 
Css1
Css1Css1
Css1
 
Asp db
Asp dbAsp db
Asp db
 
State management
State managementState management
State management
 
security configuration
security configurationsecurity configuration
security configuration
 
static dynamic html tags
 static dynamic html tags static dynamic html tags
static dynamic html tags
 
static dynamic html tags
static dynamic html tagsstatic dynamic html tags
static dynamic html tags
 
New microsoft office power point presentation
New microsoft office power point presentationNew microsoft office power point presentation
New microsoft office power point presentation
 
.Net overview
.Net overview.Net overview
.Net overview
 
Stdlib functions lesson
Stdlib functions lessonStdlib functions lesson
Stdlib functions lesson
 
enums
enumsenums
enums
 
memory
memorymemory
memory
 
array
arrayarray
array
 
storage clas
storage classtorage clas
storage clas
 
Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 

Recently uploaded

Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 

Code model

  • 1.
  • 2. Writing Code  Writing code in an ASP.NET Web form is done in three ways:  Mixed code method  The code is in the same file as the web content, mixed with the HTML code  This method is not recommended as the source code is hard to read and maintain  Inline code method  Code-behind method 2
  • 3. Writing Code (2)  Writing code in an ASP.NET web form is done in three ways:  Mixed code method  Inline code method  The code is separated in a SCRIPT section in the same file  Code-behind method 3
  • 4. Writing Code (3)  Writing code in an ASP.NET web form is done in three ways:  Mixed code method  Inline code method  Code-behind method  The code is in the code-behind page – a separate file from the HTML content  When using Visual Studio .NET this is the default method 4
  • 5. Example: Inline Code Method 5 <html> <asp:Button id="btn" runat="server"/> ... </html> <script Language="c#" runat="server"> private void btn_Click(object sender, System.EventArgs e) { ... } </script>
  • 6.
  • 7. Code-behind Model  A separate compiled file containing the program logic of the page  Each web page has its own code-behind page  Has the same name as the web page to which it is attached  The file extension is .aspx.cs  The two files are built into one when the application is started 7
  • 8. How Does Code-behind Work?  To associate an .aspx page to its code-behind class the @Page directive is used  VS.NET adds three attributes to the @Page directive:  Inherits – allows the .aspx page to derive from the code-behind class  Codebehind – used internally by Visual Studio .NET to associate the files  Src – contains the name of the code-behind page  Used if the application is not precompiled 8
  • 9. JIT Compilation  The Code-behind page can be either precompiled or just- in-time (JIT) Compiled  JIT compilation  A compilation at first request  Set by the Src attribute of the @Page directive  VS.NET doesn’t add it by default 9
  • 10. Precompilation  Precompilation  Avoids the delay at first request  Simplifies the deployment of the web application  The source code of the code-behind class is not necessary 10

Editor's Notes

  1. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  2. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  3. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  4. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  5. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  6. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  7. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  8. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  9. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*
  10. (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*