SlideShare a Scribd company logo
ASP .NET
Web Form Fundamentals



     For Beginners
       http://www.rajpatsystems.com
ASP.NET Application
An ASP.NET application is a combination of files,
  pages, handlers, modules, and executable
  code that can be invoked from a virtual
  directory (and, optionally, its subdirectories)
  on a web server. In other words, the virtual
  directory is the basic grouping structure that
  delimits an application.



                  http://www.rajpatsystems.com
http://www.rajpatsystems.com
ASP.NET File Types




 http://www.rajpatsystems.com
ASP.NET Application Directories




           http://www.rajpatsystems.com
Server Controls
• Server controls are created and configured as
  objects. They run on the web server and they
  automatically provide their own HTML output.
• Server controls behave like their Windows
  counterparts by maintaining state and raising
  events that you can react to in code.
• ASP.NET actually provides two sets of server-
  side controls that you can incorporate into
  your web forms.

                 http://www.rajpatsystems.com
HTML server controls & Web controls
• HTML server controls: These are server-based equivalents
  for standard HTML elements.
   – These controls are ideal if you’re a seasoned web programmer
     who prefers to work with familiar HTML tags (at least at first).
   – They are also useful when migrating ordinary HTML pages or
     ASP pages to ASP.NET, because they require the fewest changes.
• Web controls: These are similar to the HTML server
  controls, but they provide a richer object model with a
  variety of properties for style and formatting details.
   – They also provide more events and more closely resemble the
     controls used for Windows development.
   – Web controls also feature some user interface elements that
     have no direct HTML equivalent, such as the GridView, Calendar,
     and validation controls.

                         http://www.rajpatsystems.com
HTML Server Controls
•   HTML server controls provide an object interface for standard HTML elements.
    They provide three key features:
•   They generate their own interface: You set properties in code, and the underlying
    HTML tag is created automatically when the page is rendered and sent to the
    client.
•   They retain their state: Because the Web is stateless, ordinary web pages need to
    do a lot of work to store information between requests.
     – HTML server controls handle this task automatically. For example, if the user selects an item in
       a list box, that item remains selected the next time the page is generated.
     – Or, if your code changes the text in a button, the new text sticks the next time the page is
       posted back to the web server.
•   They fire server-side events: For example, buttons fire an event when clicked, text
    boxes fire an event when the text they contain is modified, and so on.
     – Your code can respond to these events, just like ordinary controls in a Windows application. In
       ASP code, everything is grouped into one block that executes from start to finish.
     – With event-based programming, you can easily respond to individual user actions and create
       more structured code.
     – If a given event doesn’t occur, the event-handler code won’t be executed.




                                      http://www.rajpatsystems.com
The HTML Control Classes




      http://www.rajpatsystems.com
http://www.rajpatsystems.com
http://www.rajpatsystems.com
Important HTML Control Properties




            http://www.rajpatsystems.com
http://www.rajpatsystems.com
How ASP .NET Application Works
•   First, the request for the page is sent to the web server. If you’re running a
    live site, the web server is almost certainly IIS. If you’re running the page
    in Visual Studio, the request is sent to the built-in test server.
•   The web server determines that the .aspx file extension is registered with
    ASP.NET and passes it to the ASP.NET worker process. If the file extension
    belonged to another service (as it would for .asp or .html files), ASP.NET
    would never get involved.
•   If this is the first time a page in this application has been requested,
    ASP.NET automatically creates the application domain. It also compiles all
    the web page code for optimum performance, and caches the compiled
    files in the directory c:Windows
    Microsoft.NETFrameworkv2.0.50727Temporary ASP.NET Files. If this ask
    has already been performed, ASP.NET will reuse the compiled version of
    the page.
•   The compiled aspx page acts like a miniature program. It starts firing
    events (most notably, the Page.Load event). However, you haven’t created
    an event handler for that event, so no code runs. At this stage, everything
    is working together as a set of in-memory .NET objects.
•   When the code is finished, ASP.NET asks every control in the web page to
    render itself into the corresponding HTML markup.
•   The final page is sent to the user, and the application ends.
                               http://www.rajpatsystems.com
http://www.rajpatsystems.com
The HtmlControl Base Class
• Every HTML control inherits from the base
  class HtmlControl. This relationship means
  that every HTML control will support a basic
  set of properties and features.




                  http://www.rajpatsystems.com
http://www.rajpatsystems.com
http://www.rajpatsystems.com
The HtmlContainerControl Class
•   Any HTML control that requires a closing tag inherits from the HtmlContainer class
    (which in turn inherits from the more basic HtmlControl class). For example,
    elements such as <a>, <form>, and <div> always use a closing tag, because they
    can contain other HTML elements.

•   On the other hand, elements such as <img> and <input> are used only as stand-
    alone tags. Thus, the HtmlAnchor, HtmlForm, and HtmlGenericControl classes
    inherit from

•   HtmlContainerControl, while HtmlInputImage and HtmlInputButton do not. The
    HtmlContainer control adds two properties to those defined in HtmlControl.




                                                                  http://www.rajpatsystems.com
The HtmlInputControl Class
•   This control defines some properties that are used for the <input>
    element. As you’ve already learned, the <input> element can represent
    different controls, depending on the type attribute. The <input
    type="text"> element is a text box and <input type="submit"> is a button.




                              http://www.rajpatsystems.com
The Page Class
• Every web page is a custom class that inherits
  from System.Web.UI.Page.
• By inheriting from this class, your web page
  class acquires a number of properties and
  methods that your code can use.
• These include properties for enabling caching,
  validation, and tracing


                  http://www.rajpatsystems.com
http://www.rajpatsystems.com
Sending the User to a New Page
• Click <a href="newpage.aspx">here</a> to go to
  newpage.aspx.
• HttpResponse.Redirect()
   – you can get access to the current HttpResponse object
     through the Page.Response property.
   – Response.Redirect("newpage.aspx");
   – Response.Redirect("http://www.prosetech.com");
• HttpServerUtility.Transfer()
   – An HttpServerUtility object is provided through the
     Page.Server property
   – Server.Transfer("newpage.aspx");

                      http://www.rajpatsystems.com
HTML Encoding




  http://www.rajpatsystems.com
Application Events




    http://www.rajpatsystems.com
The Global.asax File
• To add a Global.asax file to an application in
   Visual Studio, choose Website –> Add New
 Item, and select the Global Application Class file
   type. Then, click OK.




                   http://www.rajpatsystems.com
ASP.NET Configuration
• Every web application includes a web.config file that configures
  fundamental settings everything from the way error messages are
  shown to the security settings that lock out unwanted visitors.
• The ASP.NET configuration files have several key advantages:
   – They are never locked: You can update web.config settings at any
     point, even while your application is running. If there are any requests
     currently under way, they’ll continue to use the old settings, while
     new requests will get the changed settings right away.
   – They are easily accessed and replicated: Provided you have the
     appropriate network rights, you can change a web.config file from a
     remote computer. You can also copy the web.config file and use it to
     apply identical settings to another application or another web server
     that runs the same application in a web farm scenario.
   – The settings are easy to edit and understand: The settings in the
     web.config file are humanreadable, which means they can be edited
     and understood without needing a special configuration tool.

                            http://www.rajpatsystems.com
The web.config File
• The web.config file uses a predefined XML format. The entire
  content of the file is nested in a root <configuration> element.
  Inside this element are several more subsections, some of which
  you’ll never change, and others which are more important.




                         http://www.rajpatsystems.com
Nested Configuration
• ASP.NET uses a multilayered configuration system that allows you to
  set settings at different levels.
   – Every web server starts with some basic settings that are defined in
     two configuration files in the
     c:WindowsMicrosoft.NETFrameworkv2.0.50727Config directory.

   – These two files are machine.config and web.config. Generally, you
     won’t edit either of these files manually, because they affect the
     entire computer. Instead, you’ll configure the web.config file in your
     web application folder. Using that file, you can set additional settings
     or override the defaults that are configured in the two system files.

   – More interestingly, you can use different settings for different parts of
     your application. To use this technique, you need to create additional
     subdirectories inside your virtual directory. These subdirectories can
     contain their own web.config files with additional settings.

                             http://www.rajpatsystems.com
http://www.rajpatsystems.com
Storing Custom Settings in the
                web.config File
•   ASP.NET also allows you to store your own settings in the web.config file,
    in an element called <appSettings>. Note that the <appSettings> element
    is nested in the root <configuration> element.




                              http://www.rajpatsystems.com
The custom settings that you add are written as simple string
  variables. You might want to use a special web.config
  setting for several reasons:
   – To centralize an important setting that needs to be used in
     many different pages: For example, you could create a variable
     that stores a database query. Any page that needs to use this
     query can then retrieve this value and use it.
   – To make it easy to quickly switch between different modes of
     operation: For example, you might create a special debugging
     variable. Your web pages could check for this variable and, if it’s
     set to a specified value, output additional information to help
     you test the application.
   – To set some initial values: Depending on the operation, the user
     might be able to modify these values, but the web.config file
     could supply the defaults.

• You can enter custom settings using an <add> element that
  identifies a unique variable name (key) and the variable
  contents (value).    http://www.rajpatsystems.com
http://www.rajpatsystems.com
http://www.rajpatsystems.com

More Related Content

PPTX
Introduction to ASP.NET
PPT
Mutual fund ppt
PPTX
Introduction to Database
PPTX
Mendix Platform
PPTX
Routing Presentation
PDF
Asp.net state management
PDF
Overview of Low-code
Introduction to ASP.NET
Mutual fund ppt
Introduction to Database
Mendix Platform
Routing Presentation
Asp.net state management
Overview of Low-code

What's hot (20)

PDF
Basics of JavaScript
PPT
RichControl in Asp.net
PPTX
Visual Basic Controls ppt
PDF
Javascript basics
PPTX
Presentation on "An Introduction to ReactJS"
PPTX
Web Application
PPTX
Client side scripting and server side scripting
PPTX
Introduction to Angularjs
PPT
Javascript
PPTX
Front-end development introduction (HTML, CSS). Part 1
PDF
jQuery for beginners
PPTX
Static and Dynamic webpage
PPT
Scripting languages
PPT
Custom Controls in ASP.net
PPT
Developing an ASP.NET Web Application
PDF
Web Development with HTML5, CSS3 & JavaScript
PDF
6. Web Publishing
Basics of JavaScript
RichControl in Asp.net
Visual Basic Controls ppt
Javascript basics
Presentation on "An Introduction to ReactJS"
Web Application
Client side scripting and server side scripting
Introduction to Angularjs
Javascript
Front-end development introduction (HTML, CSS). Part 1
jQuery for beginners
Static and Dynamic webpage
Scripting languages
Custom Controls in ASP.net
Developing an ASP.NET Web Application
Web Development with HTML5, CSS3 & JavaScript
6. Web Publishing
Ad

Viewers also liked (20)

PPT
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
PDF
Windows Forms For Beginners Part - 3
PDF
Windows Forms For Beginners Part 5
PDF
Object Oriented Programming Concepts
PDF
Windows Forms For Beginners Part - 4
PDF
Windows Forms For Beginners Part - 2
PDF
Windows Forms For Beginners Part - 1
PDF
OOP with C#
PPT
c#.Net Windows application
PDF
Object-oriented Programming-with C#
PPT
Concepts of Asp.Net
PPT
Tootimes
PDF
The Future in designing for the sex(es)
KEY
เสนอค่าย
PPT
Learning with Quest Atlantis in Singapore
PPT
Looppa case study (Guarida)
PPTX
WTI - Storytelling and Social Media for Business Owners - B Gemmell
PPT
Teaching disgrace using Second Life
.net training | learn .net | Microsoft dot net Course | Microsoft dot net onl...
Windows Forms For Beginners Part - 3
Windows Forms For Beginners Part 5
Object Oriented Programming Concepts
Windows Forms For Beginners Part - 4
Windows Forms For Beginners Part - 2
Windows Forms For Beginners Part - 1
OOP with C#
c#.Net Windows application
Object-oriented Programming-with C#
Concepts of Asp.Net
Tootimes
The Future in designing for the sex(es)
เสนอค่าย
Learning with Quest Atlantis in Singapore
Looppa case study (Guarida)
WTI - Storytelling and Social Media for Business Owners - B Gemmell
Teaching disgrace using Second Life
Ad

Similar to Asp .net web form fundamentals (20)

PPTX
Overview of ASP.Net by software outsourcing company india
PPTX
Lecture slides_Introduction to ASP.NET presentation
ZIP
ASP.Net Presentation Part1
PPTX
PDF
C sharp and asp.net interview questions
PPTX
Web techh
PPTX
Web tech
PPTX
Web tech
PPTX
Web tech
PPTX
Asp introduction
PPT
Asp.net architecture
PPTX
Parallelminds.asp.net with sp
PPTX
ASP.NET Lecture 1
PPT
Asp.net server controls
PPTX
Ch 04 asp.net application
PPTX
Programming web application
PPTX
Web forms in ASP.net
PPTX
Asp.net With mvc handson
PPTX
Introduction to asp
PPTX
Introducing asp
Overview of ASP.Net by software outsourcing company india
Lecture slides_Introduction to ASP.NET presentation
ASP.Net Presentation Part1
C sharp and asp.net interview questions
Web techh
Web tech
Web tech
Web tech
Asp introduction
Asp.net architecture
Parallelminds.asp.net with sp
ASP.NET Lecture 1
Asp.net server controls
Ch 04 asp.net application
Programming web application
Web forms in ASP.net
Asp.net With mvc handson
Introduction to asp
Introducing asp

Asp .net web form fundamentals

  • 1. ASP .NET Web Form Fundamentals For Beginners http://www.rajpatsystems.com
  • 2. ASP.NET Application An ASP.NET application is a combination of files, pages, handlers, modules, and executable code that can be invoked from a virtual directory (and, optionally, its subdirectories) on a web server. In other words, the virtual directory is the basic grouping structure that delimits an application. http://www.rajpatsystems.com
  • 4. ASP.NET File Types http://www.rajpatsystems.com
  • 5. ASP.NET Application Directories http://www.rajpatsystems.com
  • 6. Server Controls • Server controls are created and configured as objects. They run on the web server and they automatically provide their own HTML output. • Server controls behave like their Windows counterparts by maintaining state and raising events that you can react to in code. • ASP.NET actually provides two sets of server- side controls that you can incorporate into your web forms. http://www.rajpatsystems.com
  • 7. HTML server controls & Web controls • HTML server controls: These are server-based equivalents for standard HTML elements. – These controls are ideal if you’re a seasoned web programmer who prefers to work with familiar HTML tags (at least at first). – They are also useful when migrating ordinary HTML pages or ASP pages to ASP.NET, because they require the fewest changes. • Web controls: These are similar to the HTML server controls, but they provide a richer object model with a variety of properties for style and formatting details. – They also provide more events and more closely resemble the controls used for Windows development. – Web controls also feature some user interface elements that have no direct HTML equivalent, such as the GridView, Calendar, and validation controls. http://www.rajpatsystems.com
  • 8. HTML Server Controls • HTML server controls provide an object interface for standard HTML elements. They provide three key features: • They generate their own interface: You set properties in code, and the underlying HTML tag is created automatically when the page is rendered and sent to the client. • They retain their state: Because the Web is stateless, ordinary web pages need to do a lot of work to store information between requests. – HTML server controls handle this task automatically. For example, if the user selects an item in a list box, that item remains selected the next time the page is generated. – Or, if your code changes the text in a button, the new text sticks the next time the page is posted back to the web server. • They fire server-side events: For example, buttons fire an event when clicked, text boxes fire an event when the text they contain is modified, and so on. – Your code can respond to these events, just like ordinary controls in a Windows application. In ASP code, everything is grouped into one block that executes from start to finish. – With event-based programming, you can easily respond to individual user actions and create more structured code. – If a given event doesn’t occur, the event-handler code won’t be executed. http://www.rajpatsystems.com
  • 9. The HTML Control Classes http://www.rajpatsystems.com
  • 12. Important HTML Control Properties http://www.rajpatsystems.com
  • 14. How ASP .NET Application Works • First, the request for the page is sent to the web server. If you’re running a live site, the web server is almost certainly IIS. If you’re running the page in Visual Studio, the request is sent to the built-in test server. • The web server determines that the .aspx file extension is registered with ASP.NET and passes it to the ASP.NET worker process. If the file extension belonged to another service (as it would for .asp or .html files), ASP.NET would never get involved. • If this is the first time a page in this application has been requested, ASP.NET automatically creates the application domain. It also compiles all the web page code for optimum performance, and caches the compiled files in the directory c:Windows Microsoft.NETFrameworkv2.0.50727Temporary ASP.NET Files. If this ask has already been performed, ASP.NET will reuse the compiled version of the page. • The compiled aspx page acts like a miniature program. It starts firing events (most notably, the Page.Load event). However, you haven’t created an event handler for that event, so no code runs. At this stage, everything is working together as a set of in-memory .NET objects. • When the code is finished, ASP.NET asks every control in the web page to render itself into the corresponding HTML markup. • The final page is sent to the user, and the application ends. http://www.rajpatsystems.com
  • 16. The HtmlControl Base Class • Every HTML control inherits from the base class HtmlControl. This relationship means that every HTML control will support a basic set of properties and features. http://www.rajpatsystems.com
  • 19. The HtmlContainerControl Class • Any HTML control that requires a closing tag inherits from the HtmlContainer class (which in turn inherits from the more basic HtmlControl class). For example, elements such as <a>, <form>, and <div> always use a closing tag, because they can contain other HTML elements. • On the other hand, elements such as <img> and <input> are used only as stand- alone tags. Thus, the HtmlAnchor, HtmlForm, and HtmlGenericControl classes inherit from • HtmlContainerControl, while HtmlInputImage and HtmlInputButton do not. The HtmlContainer control adds two properties to those defined in HtmlControl. http://www.rajpatsystems.com
  • 20. The HtmlInputControl Class • This control defines some properties that are used for the <input> element. As you’ve already learned, the <input> element can represent different controls, depending on the type attribute. The <input type="text"> element is a text box and <input type="submit"> is a button. http://www.rajpatsystems.com
  • 21. The Page Class • Every web page is a custom class that inherits from System.Web.UI.Page. • By inheriting from this class, your web page class acquires a number of properties and methods that your code can use. • These include properties for enabling caching, validation, and tracing http://www.rajpatsystems.com
  • 23. Sending the User to a New Page • Click <a href="newpage.aspx">here</a> to go to newpage.aspx. • HttpResponse.Redirect() – you can get access to the current HttpResponse object through the Page.Response property. – Response.Redirect("newpage.aspx"); – Response.Redirect("http://www.prosetech.com"); • HttpServerUtility.Transfer() – An HttpServerUtility object is provided through the Page.Server property – Server.Transfer("newpage.aspx"); http://www.rajpatsystems.com
  • 24. HTML Encoding http://www.rajpatsystems.com
  • 25. Application Events http://www.rajpatsystems.com
  • 26. The Global.asax File • To add a Global.asax file to an application in Visual Studio, choose Website –> Add New Item, and select the Global Application Class file type. Then, click OK. http://www.rajpatsystems.com
  • 27. ASP.NET Configuration • Every web application includes a web.config file that configures fundamental settings everything from the way error messages are shown to the security settings that lock out unwanted visitors. • The ASP.NET configuration files have several key advantages: – They are never locked: You can update web.config settings at any point, even while your application is running. If there are any requests currently under way, they’ll continue to use the old settings, while new requests will get the changed settings right away. – They are easily accessed and replicated: Provided you have the appropriate network rights, you can change a web.config file from a remote computer. You can also copy the web.config file and use it to apply identical settings to another application or another web server that runs the same application in a web farm scenario. – The settings are easy to edit and understand: The settings in the web.config file are humanreadable, which means they can be edited and understood without needing a special configuration tool. http://www.rajpatsystems.com
  • 28. The web.config File • The web.config file uses a predefined XML format. The entire content of the file is nested in a root <configuration> element. Inside this element are several more subsections, some of which you’ll never change, and others which are more important. http://www.rajpatsystems.com
  • 29. Nested Configuration • ASP.NET uses a multilayered configuration system that allows you to set settings at different levels. – Every web server starts with some basic settings that are defined in two configuration files in the c:WindowsMicrosoft.NETFrameworkv2.0.50727Config directory. – These two files are machine.config and web.config. Generally, you won’t edit either of these files manually, because they affect the entire computer. Instead, you’ll configure the web.config file in your web application folder. Using that file, you can set additional settings or override the defaults that are configured in the two system files. – More interestingly, you can use different settings for different parts of your application. To use this technique, you need to create additional subdirectories inside your virtual directory. These subdirectories can contain their own web.config files with additional settings. http://www.rajpatsystems.com
  • 31. Storing Custom Settings in the web.config File • ASP.NET also allows you to store your own settings in the web.config file, in an element called <appSettings>. Note that the <appSettings> element is nested in the root <configuration> element. http://www.rajpatsystems.com
  • 32. The custom settings that you add are written as simple string variables. You might want to use a special web.config setting for several reasons: – To centralize an important setting that needs to be used in many different pages: For example, you could create a variable that stores a database query. Any page that needs to use this query can then retrieve this value and use it. – To make it easy to quickly switch between different modes of operation: For example, you might create a special debugging variable. Your web pages could check for this variable and, if it’s set to a specified value, output additional information to help you test the application. – To set some initial values: Depending on the operation, the user might be able to modify these values, but the web.config file could supply the defaults. • You can enter custom settings using an <add> element that identifies a unique variable name (key) and the variable contents (value). http://www.rajpatsystems.com