SlideShare a Scribd company logo
WEB FORMS
ASP.NET pages (officially known as web forms) are a
vital part of an ASP.NET application.


 Provide the actual output of a web application—the
web pages that clients request and view in their browsers.


 Web forms allow you to create a web application using
the some control-based interface as a Windows
application.
  1
Page Processing
 Goal of ASP.NET developers is to develop
web forms in the same way that Windows
developers can build applications.
 Web applications are very different from
traditional rich desktop/client applications:
      Web applications execute on the server.
      Web applications are stateless.
 2
HTML Forms
 Simplest way to send client-side data to the server is
using a <form> tag
 Inside the <form> tag, can place other <input> tags to
represent basic user interface ingredients




   3
HTML Forms cont..


 ASP.NET uses control model.

    string firstName = txtFirstName.Text;




4
Dynamic User Interface
 Control model makes life easier for retrieving form information

 In classic ASP insert a script block that would write the raw HTML
        string message = "<span style="color:Red">Welcome " +
        FirstName + " " + LastName + "</span>";
        Response.Write(message);

 On the other hand, with Label control in ASP.NET

     <asp:Label id="lblWelcome" runat="server" />
  Now you can simply set its properties

  lblWelcome.Text = "Welcome " + FirstName + " " + LastName;
  lblWelcome.ForeColor = Color.Red;
Note: Not Necessary to KNOW HTML markup syntax.
   5
     Hides the low-level HTML details.
The ASP.NET Event Model
 Classic ASP uses a linear processing model.

Code execution is from start to end.
More code for even simple web page.
(Example of three buttons on HTML form)
 script code must determine which button is clicked
   and execute code accordingly

 ASP.NET provides event-driven model.


  6
The ASP.NET Event Model cont..
Here’s a brief outline of event driven model:
1. Your page runs for the first time. ASP.NET
   creates page, & control objects, the
   initialization code executes, and then the page
   is rendered to HTML and returned to the
   client.

2. At some point, the user does something that
   triggers a postback, such as clicking a button.
   & page is submitted with all the form data.

3. ASP.NET intercepts the returned page and re-
 7 creates the page objects.
The ASP.NET Event Model cont..
4. Next, ASP.NET checks what operation
   triggered the postback, and raises the
   appropriate event procedure.
5. The modified page is rendered to HTML
   and returned to the client. The page
   objects are released from memory.
   If another postback occurs, ASP.NET
   repeats the process in steps 2 through 4.
POSTBACK
1.User request web form from server

2.Web server respond back with requested web form.

3.User enters the data and submits the form to web server.

4.Web server process the form and sends the result back
to the client

Step 3 ????
Step 3 & Step 4 ????

PostBack is the name given to the process of submitting
an ASP.NET page to the server for processing.
Automatic Postbacks
 All client action cannot be handled. e.g. mouse
movement because of server side processing.
 If want to do, can use Java Script or Ajax.
 ASP.NET web controls extend this model with an
automatic postback feature.
 To use automatic postback set the AutoPostBack
property of a web control to true (the default is false)
 ASP.NET adds a JavaScript function to the rendered
HTML page named __doPostBack() (AutoPostBack
=true)

 10
View State
 View state solves another problem that occurs
because of the stateless nature of HTTP—lost
changes.
 ASP.NET has its own integrated state
serialization mechanism.
 ASP.NET examines all the properties, if changed
makes a note of this information in a name/value
collection.
 ASP.NET takes all the information it has
collected and then serializes it as a Base64 string.
  11
View State cont..
The next time the page is posted back, ASP.NET follows these
steps:
1. ASP.NET re-creates the page and control objects based on
   its defaults (first requested state)
2.        Next, ASP.NET deserializes the view state information and
          updates all the controls.
3. ASP.NET adjusts the page according to the posted back
   form data.
4.        Now event-handling code can get involved.
          e.g. code can react to change the page, move to a new
          page, or perform a completely different operation.
     12
View State (First Request) cont..




  13
View State(Postback Request) cont..




14
View State cont..
Note: Even if you set EnableViewState to false, the
control can still hold onto a smaller amount of
view state information.
This privileged view state information is known as
control state, and it can never be disabled.

Note: It is absolutely essential to your success as an
ASP.NET programmer to remember that the web form
is re-created with every round-trip. It does not persist
or remain in memory longer than it takes to render a
single request.
 15
Web Forms Processing Stages
 On the server side, processing an ASP.NET web
form takes place in stages.
 The following list shows the major processing
stages
     • Page framework initialization
     • User code initialization
     • Validation
     • Event handling
     • Automatic data binding
     • Cleanup
16
Web Forms Processing Stages cont..




17
Page Framework Initialization

 ASP.NET first creates the page
 Generates all the controls defined
 ASP.NET deserializes the view state information
(not being requested for the first if it’s postback),
 Next Page.Init event fires (rarely handled by the
web page, because it’s still too early to perform
page initialization)

  18
User Code Initialization
 At this stage of the processing, the Page.Load event is fired.
 The Page.Load event always fires, regardless of whether the
page is being requested for the first time or whether it is being
requested as part of a postback.
 To determine the current state of the page, check the
IsPostBack property of the page, which will be false the first
time the page is requested. Here’s an example:
if (!IsPostBack)
{
        // It's safe to initialize the controls for the first time.
        FirstName.Text = "Enter your name here";
}
   19
Validation
 ASP.NET includes validation controls
that can automatically validate other user
input controls and display error messages.
 Validation controls fire after the page is
loaded but before any other events take
Place.
 validation controls are self-sufficient

 20
Event Handling
 At this point, the page is fully loaded and validated.
 ASP.NET will now fire all the events since the last postback
     Immediate response events
     Change events
 ASP.NET’s event model is still quite different from a traditional Windows
environment
 If you change text in the text box and click submit button, ASP.NET raises all
of the following events (in this order):
        • Page.Init
        • Page.Load
        • TextBox.TextChanged
        • Button.Click
        • Page.PreRender
   21   • Page.Unload
Automatic Data Binding
 When you use the data source controls, ASP.NET
automatically performs updates and queries against your data
source as part of the page life cycle.
 Changes are performed after all the control events have
been handled but just before the Page.PreRender event fires.
 After the Page.PreRender event fires, the data source
controls perform their queries and insert the retrieved data
into linked controls.
 This is the last stop in the page life cycle.
 Page.PreRender is last action before the page is rendered
into HTML.
   22
Cleanup
 At the end of its life cycle, the page is rendered to HTML.
 Page.Unload event is fired.
 At this point, the page objects are still available, but the
final HTML is already rendered and can’t be changed.
 garbage collection service that runs periodically to release
memory tied to objects
 unmanaged resources must be to release explicitly (e.g.
Windows file handles and ODBC database connections)
 When the garbage collector collects the page, the
Page.Disposed event fires.

   23
Summary of Web Forms Processing Stages


       • Page framework initialization
       • User code initialization
       • Validation
       • Event handling
       • Automatic data binding
       • Cleanup


  24
The Page As a Control Container
 To render a page, the web form needs to collaborate with all
its constituent controls.


 When ASP.NET first creates a page, it inspects the .aspx file
for each element it finds with the runat="server" attribute, it
creates and configures a control object, and then it adds this
control as a child control of the page.


 Page.Controls collection contains all child controls on the
page
 ASP.NET models the entire page using control objects,
including elements that don’t correspond to server-side
   25
content.
The Page Header
 Web  form can also contain a single HtmlHead
control, which provides server-side access to the <head>
tag.

 Visual Studio default is to always make the <head> tag
into a server-side control

 Head includes other details such as the title, metadata
tags (useful for providing keywords to search engines)

 Title: This is the title of the HTML page
 StyleSheet: IStyleSheet object that represents inline
  26
styles
The Page Class
 All web forms are actually instances of   the ASP.NET Page class
(System.Web.UI namespace)
 Code-behind class explicitly derives from System.Web.UI.Page.
 means that every web form you create is equipped with an enormous
amount of out-of-the-box functionality
 Page class gives your code the following extremely useful properties:
        • Session
        • Application
        • Cache
        • Request
        • Response
        • Server
        • User
   27   • Trace
Session, Application, and Cache
 The Session object is an instance of the
System.Web.SessionState.HttpSessionState class.
 The Session object provides dictionary-style access to a set of
name/value pairs.
 Session state is often used to maintain user specific information.
 The Application object is an instance of the
System.Web.HttpApplicationState class
 Data is global to the entire application.
 Cache object is an instance of the System.Web.Caching.Cache
class.
 Scalable storage mechanism because ASP.NET can remove
objects if server memory becomes scarce.
   28
Request Object
 An instance of the System.Web.HttpRequest
class.
 Object represents the values and properties of
the HTTP request
 contains all the URLparameters and all other
information sent by a client.
 Much of the information provided by the
Request object is wrapped by higher-level
abstractions.
 Can examine cookies
29
Request Object cont..
   Property                        Description
 AnonymousID      identifies the current user
ApplicationPath   ApplicationPath gets the ASP.NET
      and         application’s virtual directory (URL), while
PhysicalApplicat  PhysicalApplicationPath gets the “real”
    ionPath       directory.
    Browser       provides a link to an
                  HttpBrowserCapabilities object
ClientCertificate HttpClientCertificate object that gets the
                  security certificate for the current request
      Cookies     gets the collection of cookies sent with this
   30
                  request
Request Object cont..
       Property                     Description
Form              Represents the collection of form variables
                  that were posted back to the page.
Headers and       collection of HTTP headers and server
ServerVariables   variables, indexed by name.
IsAuthenticated & These return true if the user has been
IsSecureConnectio successfully authenticated and if the user is
n                 connected over SSL (Secure Sockets Layer).
IsLocal           This returns true if the user is requesting the
                  page from the local computer.
QueryString       provides the parameters that were passed
                  along with thequery string.
  31
Request Object cont..
      Property                Description
Url and       Uri object that represents the current
UrlReferrer   address for
              the page and the page where the user
              is coming from
UserAgent     a string representing the browser type.
UserHostAddre get the IP address and the DNS name
ss and        of the remote client
UserHostName
UserLanguages provides a sorted string array that lists
              the client’s language preferences.
 32
Response object

 Response object is an instance of the
System.Web.HttpResponse class
 HttpResponse does still provide some
important functionality—namely, cookie and
Redirect() method



 33
Response object cont..
    Member                                  Description
BufferOutput        Can set true or false
Cache               HttpCachePolicy object that allows you to configure
                    output caching
Cookies             collection of cookies sent with the response
Expires and         these properties to cache the rendered HTML
ExpiresAbsolute
sClientConnected    Boolean value indicating whether the client is still
                    connected to the server
Redirect()          transfers the user to another page in your application
                    or a different website
Write()             write text directly to the response
                    stream.
BinaryWrite() and   allow you to take binary content from a byte array
WriteFile()
   34
                    or from a file and write it directly to the response
                    stream
Server Object
Server object is an instance of the
System.Web.HttpServerUtility class.
   Member                       Description
MachineName     Computer name of the computer on which
                the page is running.
GetLastError()  Retrieves the exception object for the most
                recently encountered error.
HtmlEncode()    Changes an ordinary string into a string
and             with legal HTML characters (and back
HtmlDecode()    again).
UrlEncode() and Changes an ordinary string into a string
UrlDecode()     with legal URL characters (and back
   35
                again).
Server Object cont..
    Member                     Description
UrlTokenEncode   Performs the same work as
() and           UrlEncode() and UrlDecode(), except
UrlTokenDecode   they work on a byte array that
()               contains Base64-encoded data.
MapPath()        Returns the physical file path that
                 corresponds to a specified virtual file
                 path.
Transfer()       Transfers execution to another web
                 page in the current application.
 36
Common HTML Entities

Result        Description       Encoded
                                 Entity
          Non breaking space     &nbsp;
      <   Less-than symbol        &lt;
      >   Greater-than symbol     &gt;
      &   Ampersand              &amp;
      "   Quotation mark         &amp;
 37
User Object
 User object represents information about the user
  making the request of the web server

 allows you to test that user’s role membership.

 Implements System.Security.Principal.Iprincipal

 can authenticate a user based on specific class
  depends Windows account information using IIS or
 through cookie-based authentication with a
 dedicated login page.

More Related Content

What's hot (20)

Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
Raed Aldahdooh
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
Surbhi Panhalkar
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
Eyal Vardi
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
prabhu rajendran
 
CSS
CSSCSS
CSS
People Strategists
 
Web controls
Web controlsWeb controls
Web controls
Sarthak Varshney
 
Express js
Express jsExpress js
Express js
Manav Prasad
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
Naveen Sihag
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
Information Technology
 
Css Ppt
Css PptCss Ppt
Css Ppt
Hema Prasanth
 
JDBC
JDBCJDBC
JDBC
People Strategists
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
priya Nithya
 
ASP.NET Basics
ASP.NET Basics ASP.NET Basics
ASP.NET Basics
baabtra.com - No. 1 supplier of quality freshers
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
HTML/HTML5
HTML/HTML5HTML/HTML5
HTML/HTML5
People Strategists
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
Nidhi mishra
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
Java script
Java scriptJava script
Java script
Abhishek Kesharwani
 

Viewers also liked (20)

The ASP.NET Web API for Beginners
The ASP.NET Web API for BeginnersThe ASP.NET Web API for Beginners
The ASP.NET Web API for Beginners
Kevin Hazzard
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
Dr. Awase Khirni Syed
 
Data controls ppt
Data controls pptData controls ppt
Data controls ppt
Iblesoft
 
data controls in asp.net
data controls in asp.netdata controls in asp.net
data controls in asp.net
subakrish
 
Asp.net
 Asp.net Asp.net
Asp.net
Dinesh kumar
 
Asp.net basic
Asp.net basicAsp.net basic
Asp.net basic
Neelesh Shukla
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
habib_786
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
dimuthu22
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
Ido Flatow
 
Ch 7 data binding
Ch 7 data bindingCh 7 data binding
Ch 7 data binding
Madhuri Kavade
 
Nnnnnn
NnnnnnNnnnnn
Nnnnnn
nautami
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
Hitesh Santani
 
Standard control in asp.net
Standard control in asp.netStandard control in asp.net
Standard control in asp.net
baabtra.com - No. 1 supplier of quality freshers
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
Julie Iskander
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Peter Gfader
 
Asp.Net Control Architecture
Asp.Net Control ArchitectureAsp.Net Control Architecture
Asp.Net Control Architecture
Sundararajan Subramanian
 
Presentation on asp.net controls
Presentation on asp.net controlsPresentation on asp.net controls
Presentation on asp.net controls
Reshi Unen
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
Sireesh K
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
baabtra.com - No. 1 supplier of quality freshers
 
Presentation - Electronic Data Interchange
Presentation - Electronic Data InterchangePresentation - Electronic Data Interchange
Presentation - Electronic Data Interchange
Sharad Srivastava
 
Ad

Similar to Web forms in ASP.net (20)

ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
Julie Iskander
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
ssuserc28c7c1
 
Introductionto asp net-ppt
Introductionto asp net-pptIntroductionto asp net-ppt
Introductionto asp net-ppt
tmasyam
 
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).pptasp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
Anwar Patel
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
Paneliya Prince
 
Aspnet architecture
Aspnet architectureAspnet architecture
Aspnet architecture
phantrithuc
 
Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
parallelminder
 
How to develop asp web applications
How to develop asp web applicationsHow to develop asp web applications
How to develop asp web applications
Deepankar Pathak
 
Page life cycle
Page life cyclePage life cycle
Page life cycle
AsamHussain3
 
Asp.Net Page Life
Asp.Net Page LifeAsp.Net Page Life
Asp.Net Page Life
guest812990
 
Asp dot net long
Asp dot net longAsp dot net long
Asp dot net long
Amelina Ahmeti
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
Melick Baranasooriya
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
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
SAMIR BHOGAYTA
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asp
priya Nithya
 
Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
santoshkjogalekar
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
Sisir Ghosh
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
neeta1995
 
Asp.net
Asp.netAsp.net
Asp.net
Anchit Rajawat
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
Abhishek Sur
 
Introductionto asp net-ppt
Introductionto asp net-pptIntroductionto asp net-ppt
Introductionto asp net-ppt
tmasyam
 
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).pptasp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
Anwar Patel
 
Aspnet architecture
Aspnet architectureAspnet architecture
Aspnet architecture
phantrithuc
 
Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
parallelminder
 
How to develop asp web applications
How to develop asp web applicationsHow to develop asp web applications
How to develop asp web applications
Deepankar Pathak
 
Asp.Net Page Life
Asp.Net Page LifeAsp.Net Page Life
Asp.Net Page Life
guest812990
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
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
SAMIR BHOGAYTA
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asp
priya Nithya
 
Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
santoshkjogalekar
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
Sisir Ghosh
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
neeta1995
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
Abhishek Sur
 
Ad

Recently uploaded (20)

If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
IntroSlides-May-BuildWithAi-EarthEngine.pdf
IntroSlides-May-BuildWithAi-EarthEngine.pdfIntroSlides-May-BuildWithAi-EarthEngine.pdf
IntroSlides-May-BuildWithAi-EarthEngine.pdf
Luiz Carneiro
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
AI Creative Generates You Passive Income Like Never Before
AI Creative Generates You Passive Income Like Never BeforeAI Creative Generates You Passive Income Like Never Before
AI Creative Generates You Passive Income Like Never Before
SivaRajan47
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Scott M. Graffius
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)
Brian Ahier
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025Azure vs AWS  Which Cloud Platform Is Best for Your Business in 2025
Azure vs AWS Which Cloud Platform Is Best for Your Business in 2025
Infrassist Technologies Pvt. Ltd.
 
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und AnwendungsfälleDomino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
Domino IQ – Was Sie erwartet, erste Schritte und Anwendungsfälle
panagenda
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
Jira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : IntroductionJira Administration Training – Day 1 : Introduction
Jira Administration Training – Day 1 : Introduction
Ravi Teja
 
IntroSlides-May-BuildWithAi-EarthEngine.pdf
IntroSlides-May-BuildWithAi-EarthEngine.pdfIntroSlides-May-BuildWithAi-EarthEngine.pdf
IntroSlides-May-BuildWithAi-EarthEngine.pdf
Luiz Carneiro
 
Oracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI ProfessionalOracle Cloud Infrastructure Generative AI Professional
Oracle Cloud Infrastructure Generative AI Professional
VICTOR MAESTRE RAMIREZ
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
AI Creative Generates You Passive Income Like Never Before
AI Creative Generates You Passive Income Like Never BeforeAI Creative Generates You Passive Income Like Never Before
AI Creative Generates You Passive Income Like Never Before
SivaRajan47
 
Your startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean accountYour startup on AWS - How to architect and maintain a Lean and Mean account
Your startup on AWS - How to architect and maintain a Lean and Mean account
angelo60207
 
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Mark Zuckerberg teams up with frenemy Palmer Luckey to shape the future of XR...
Scott M. Graffius
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)Trends Report: Artificial Intelligence (AI)
Trends Report: Artificial Intelligence (AI)
Brian Ahier
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 

Web forms in ASP.net

  • 1. WEB FORMS ASP.NET pages (officially known as web forms) are a vital part of an ASP.NET application.  Provide the actual output of a web application—the web pages that clients request and view in their browsers.  Web forms allow you to create a web application using the some control-based interface as a Windows application. 1
  • 2. Page Processing  Goal of ASP.NET developers is to develop web forms in the same way that Windows developers can build applications.  Web applications are very different from traditional rich desktop/client applications:  Web applications execute on the server.  Web applications are stateless. 2
  • 3. HTML Forms  Simplest way to send client-side data to the server is using a <form> tag  Inside the <form> tag, can place other <input> tags to represent basic user interface ingredients 3
  • 4. HTML Forms cont..  ASP.NET uses control model. string firstName = txtFirstName.Text; 4
  • 5. Dynamic User Interface  Control model makes life easier for retrieving form information  In classic ASP insert a script block that would write the raw HTML string message = "<span style="color:Red">Welcome " + FirstName + " " + LastName + "</span>"; Response.Write(message);  On the other hand, with Label control in ASP.NET <asp:Label id="lblWelcome" runat="server" /> Now you can simply set its properties lblWelcome.Text = "Welcome " + FirstName + " " + LastName; lblWelcome.ForeColor = Color.Red; Note: Not Necessary to KNOW HTML markup syntax. 5 Hides the low-level HTML details.
  • 6. The ASP.NET Event Model  Classic ASP uses a linear processing model. Code execution is from start to end. More code for even simple web page. (Example of three buttons on HTML form)  script code must determine which button is clicked and execute code accordingly  ASP.NET provides event-driven model. 6
  • 7. The ASP.NET Event Model cont.. Here’s a brief outline of event driven model: 1. Your page runs for the first time. ASP.NET creates page, & control objects, the initialization code executes, and then the page is rendered to HTML and returned to the client. 2. At some point, the user does something that triggers a postback, such as clicking a button. & page is submitted with all the form data. 3. ASP.NET intercepts the returned page and re- 7 creates the page objects.
  • 8. The ASP.NET Event Model cont.. 4. Next, ASP.NET checks what operation triggered the postback, and raises the appropriate event procedure. 5. The modified page is rendered to HTML and returned to the client. The page objects are released from memory. If another postback occurs, ASP.NET repeats the process in steps 2 through 4.
  • 9. POSTBACK 1.User request web form from server 2.Web server respond back with requested web form. 3.User enters the data and submits the form to web server. 4.Web server process the form and sends the result back to the client Step 3 ???? Step 3 & Step 4 ???? PostBack is the name given to the process of submitting an ASP.NET page to the server for processing.
  • 10. Automatic Postbacks  All client action cannot be handled. e.g. mouse movement because of server side processing.  If want to do, can use Java Script or Ajax.  ASP.NET web controls extend this model with an automatic postback feature.  To use automatic postback set the AutoPostBack property of a web control to true (the default is false)  ASP.NET adds a JavaScript function to the rendered HTML page named __doPostBack() (AutoPostBack =true) 10
  • 11. View State  View state solves another problem that occurs because of the stateless nature of HTTP—lost changes.  ASP.NET has its own integrated state serialization mechanism.  ASP.NET examines all the properties, if changed makes a note of this information in a name/value collection.  ASP.NET takes all the information it has collected and then serializes it as a Base64 string. 11
  • 12. View State cont.. The next time the page is posted back, ASP.NET follows these steps: 1. ASP.NET re-creates the page and control objects based on its defaults (first requested state) 2. Next, ASP.NET deserializes the view state information and updates all the controls. 3. ASP.NET adjusts the page according to the posted back form data. 4. Now event-handling code can get involved. e.g. code can react to change the page, move to a new page, or perform a completely different operation. 12
  • 13. View State (First Request) cont.. 13
  • 15. View State cont.. Note: Even if you set EnableViewState to false, the control can still hold onto a smaller amount of view state information. This privileged view state information is known as control state, and it can never be disabled. Note: It is absolutely essential to your success as an ASP.NET programmer to remember that the web form is re-created with every round-trip. It does not persist or remain in memory longer than it takes to render a single request. 15
  • 16. Web Forms Processing Stages  On the server side, processing an ASP.NET web form takes place in stages.  The following list shows the major processing stages • Page framework initialization • User code initialization • Validation • Event handling • Automatic data binding • Cleanup 16
  • 17. Web Forms Processing Stages cont.. 17
  • 18. Page Framework Initialization  ASP.NET first creates the page  Generates all the controls defined  ASP.NET deserializes the view state information (not being requested for the first if it’s postback),  Next Page.Init event fires (rarely handled by the web page, because it’s still too early to perform page initialization) 18
  • 19. User Code Initialization  At this stage of the processing, the Page.Load event is fired.  The Page.Load event always fires, regardless of whether the page is being requested for the first time or whether it is being requested as part of a postback.  To determine the current state of the page, check the IsPostBack property of the page, which will be false the first time the page is requested. Here’s an example: if (!IsPostBack) { // It's safe to initialize the controls for the first time. FirstName.Text = "Enter your name here"; } 19
  • 20. Validation  ASP.NET includes validation controls that can automatically validate other user input controls and display error messages.  Validation controls fire after the page is loaded but before any other events take Place.  validation controls are self-sufficient 20
  • 21. Event Handling  At this point, the page is fully loaded and validated.  ASP.NET will now fire all the events since the last postback  Immediate response events  Change events  ASP.NET’s event model is still quite different from a traditional Windows environment  If you change text in the text box and click submit button, ASP.NET raises all of the following events (in this order): • Page.Init • Page.Load • TextBox.TextChanged • Button.Click • Page.PreRender 21 • Page.Unload
  • 22. Automatic Data Binding  When you use the data source controls, ASP.NET automatically performs updates and queries against your data source as part of the page life cycle.  Changes are performed after all the control events have been handled but just before the Page.PreRender event fires.  After the Page.PreRender event fires, the data source controls perform their queries and insert the retrieved data into linked controls.  This is the last stop in the page life cycle.  Page.PreRender is last action before the page is rendered into HTML. 22
  • 23. Cleanup  At the end of its life cycle, the page is rendered to HTML.  Page.Unload event is fired.  At this point, the page objects are still available, but the final HTML is already rendered and can’t be changed.  garbage collection service that runs periodically to release memory tied to objects  unmanaged resources must be to release explicitly (e.g. Windows file handles and ODBC database connections)  When the garbage collector collects the page, the Page.Disposed event fires. 23
  • 24. Summary of Web Forms Processing Stages • Page framework initialization • User code initialization • Validation • Event handling • Automatic data binding • Cleanup 24
  • 25. The Page As a Control Container  To render a page, the web form needs to collaborate with all its constituent controls.  When ASP.NET first creates a page, it inspects the .aspx file for each element it finds with the runat="server" attribute, it creates and configures a control object, and then it adds this control as a child control of the page.  Page.Controls collection contains all child controls on the page  ASP.NET models the entire page using control objects, including elements that don’t correspond to server-side 25 content.
  • 26. The Page Header  Web form can also contain a single HtmlHead control, which provides server-side access to the <head> tag.  Visual Studio default is to always make the <head> tag into a server-side control  Head includes other details such as the title, metadata tags (useful for providing keywords to search engines)  Title: This is the title of the HTML page  StyleSheet: IStyleSheet object that represents inline 26 styles
  • 27. The Page Class  All web forms are actually instances of the ASP.NET Page class (System.Web.UI namespace)  Code-behind class explicitly derives from System.Web.UI.Page.  means that every web form you create is equipped with an enormous amount of out-of-the-box functionality  Page class gives your code the following extremely useful properties: • Session • Application • Cache • Request • Response • Server • User 27 • Trace
  • 28. Session, Application, and Cache  The Session object is an instance of the System.Web.SessionState.HttpSessionState class.  The Session object provides dictionary-style access to a set of name/value pairs.  Session state is often used to maintain user specific information.  The Application object is an instance of the System.Web.HttpApplicationState class  Data is global to the entire application.  Cache object is an instance of the System.Web.Caching.Cache class.  Scalable storage mechanism because ASP.NET can remove objects if server memory becomes scarce. 28
  • 29. Request Object  An instance of the System.Web.HttpRequest class.  Object represents the values and properties of the HTTP request  contains all the URLparameters and all other information sent by a client.  Much of the information provided by the Request object is wrapped by higher-level abstractions.  Can examine cookies 29
  • 30. Request Object cont.. Property Description AnonymousID identifies the current user ApplicationPath ApplicationPath gets the ASP.NET and application’s virtual directory (URL), while PhysicalApplicat PhysicalApplicationPath gets the “real” ionPath directory. Browser provides a link to an HttpBrowserCapabilities object ClientCertificate HttpClientCertificate object that gets the security certificate for the current request Cookies gets the collection of cookies sent with this 30 request
  • 31. Request Object cont.. Property Description Form Represents the collection of form variables that were posted back to the page. Headers and collection of HTTP headers and server ServerVariables variables, indexed by name. IsAuthenticated & These return true if the user has been IsSecureConnectio successfully authenticated and if the user is n connected over SSL (Secure Sockets Layer). IsLocal This returns true if the user is requesting the page from the local computer. QueryString provides the parameters that were passed along with thequery string. 31
  • 32. Request Object cont.. Property Description Url and Uri object that represents the current UrlReferrer address for the page and the page where the user is coming from UserAgent a string representing the browser type. UserHostAddre get the IP address and the DNS name ss and of the remote client UserHostName UserLanguages provides a sorted string array that lists the client’s language preferences. 32
  • 33. Response object  Response object is an instance of the System.Web.HttpResponse class  HttpResponse does still provide some important functionality—namely, cookie and Redirect() method 33
  • 34. Response object cont.. Member Description BufferOutput Can set true or false Cache HttpCachePolicy object that allows you to configure output caching Cookies collection of cookies sent with the response Expires and these properties to cache the rendered HTML ExpiresAbsolute sClientConnected Boolean value indicating whether the client is still connected to the server Redirect() transfers the user to another page in your application or a different website Write() write text directly to the response stream. BinaryWrite() and allow you to take binary content from a byte array WriteFile() 34 or from a file and write it directly to the response stream
  • 35. Server Object Server object is an instance of the System.Web.HttpServerUtility class. Member Description MachineName Computer name of the computer on which the page is running. GetLastError() Retrieves the exception object for the most recently encountered error. HtmlEncode() Changes an ordinary string into a string and with legal HTML characters (and back HtmlDecode() again). UrlEncode() and Changes an ordinary string into a string UrlDecode() with legal URL characters (and back 35 again).
  • 36. Server Object cont.. Member Description UrlTokenEncode Performs the same work as () and UrlEncode() and UrlDecode(), except UrlTokenDecode they work on a byte array that () contains Base64-encoded data. MapPath() Returns the physical file path that corresponds to a specified virtual file path. Transfer() Transfers execution to another web page in the current application. 36
  • 37. Common HTML Entities Result Description Encoded Entity Non breaking space &nbsp; < Less-than symbol &lt; > Greater-than symbol &gt; & Ampersand &amp; " Quotation mark &amp; 37
  • 38. User Object  User object represents information about the user making the request of the web server  allows you to test that user’s role membership.  Implements System.Security.Principal.Iprincipal  can authenticate a user based on specific class depends Windows account information using IIS or through cookie-based authentication with a dedicated login page.