Telerik Software Academy ASP.NET Web Forms.

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Telerik School Academy ASP.NET MVC.
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Touch and Gestures with Xamarin Forms
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
C# Fundamentals – Part I
Introduction to ASP.NET
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
* ASP.NET Web Security SQL Injection, XSS, CSRF, Parameter Tampering, DoS Attacks, Session Hijacking ASP.NET MVC Telerik Software Academy
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Past, Present and Future Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Telerik Software Academy ASP.NET Web Forms.
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer
Telerik Software Academy End-to-end JavaScript Applications.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Doncho Minkov Telerik Software Academy academy.telerik.com Technical Trainer Next Generation for Desktop Applications.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Learn to Design Error Steady Code Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Building Rock-Solid Software Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Svetlin Nakov Telerik Corporation
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Presentation transcript:

Telerik Software Academy ASP.NET Web Forms

1. Introduction to ASP.NET Web Forms 2. Web Forms Basic Components 3. ASP.NET Sumator – Demo 4. ASP.NET Page Execution Model 5. Postbacks and VIEWSTATE 6. ASP.NET Page Directives 2

 ASP.NET Web Forms  Web application development framework  Renders HTML content at the server-side  Combines C# with HTML for dynamic content  Component-based, event-driven model  Created by from Microsoft in 2002  Powerful, but complicated, very mature  Weak control over the output HTML  Web Form == composition of nested controls in ASPX page 4

 Separate presentation from code  Code behind, unlike PHP (mixed code + HTML)  Component-based development  Event-driven architecture  Object-oriented approach  Code compilation (instead of interpreter)  Built-in state management (session, app, …)  Many others (data binding, validation, master pages, user controls, authentication, etc.) 5

Windows Server Internet Information Server (IIS) + ISAPI Filters (aspnet_isapi.dll) OWIN ASP.NET runtime (aspnet_wp.dll / w3wp.dll / Microsoft.Owin.Hosting.dll) XML-basedconfiguration (Web.config) HttpApplication Cache HttpModules Session state Authentication … HttpHandlers ASP.NET MVC controllers ASP.NET pages ASP.NET Web API SignalR … ASPX pages Html Controls AJAX Web controls User controls Master pages …

 Traditional Web pages (static HTML)  Consist of static HTML, images, styles, etc.  Execute code on the client side (JavaScript)  Need lots of AJAX to become dynamic  ASP.NET Web Forms  Execute code on the server and render HTML  Extensive use of server-side components  Allow easy integration with databases 7

 Old-fashioned Web development mixes HTML and programming code in single file (like PHP)  Hard to read, understand and maintain  Often leads to spaghetti code  ASP.NET Web Forms splits the Web pages into two parts: .aspx file containing HTML for visualization  "Code behind" files (.aspx.cs ) containing the presentation logic for particular page 8

 Class generated from the.aspx file does not derive directly from Page class  Derives from class defined in the "code behind", where it is easy to add methods, event handlers, etc.  Using "code behind" separates the presentation logic from UI visualization 9 System.Web.UI.Page TestForm.aspx.cs TestForm.aspx

 Web Forms  XML-based files describing the Web UI  Web Control  The smallest part we can use in our Web application (e.g. text box)  "Code behind"  Contains the server-side C# code behind pages  Web.config  Contains ASP.NET application configuration 11

 An ASP.NET Web Form is a programmable Web page (.aspx file)  Acts as a Web-based user interface (UI) of the ASP.NET Web Forms applications  XML-based language, like XHTML  Consists of HTML, C# code and controls  Executed at the server-side by ASP.NET  Rendered to HTML by the ASP.NET runtime  Have complex execution model (many steps) 12

 The functionality of the Web form is defined by attributes: Page, Codebehind, Inherits 13 Page Language="C#" Codebehind="TestWebForm.aspx.cs" Codebehind="TestWebForm.aspx.cs" Inherits="FirstApp.TestWebForm" %> Inherits="FirstApp.TestWebForm" %> <html> First WebForm First WebForm … … <asp:TextBox ID="textCustomerName" runat="server" <asp:TextBox ID="textCustomerName" runat="server" Text="Customer Name: ">… Text="Customer Name: ">… </html> Always put ID="…" and runat="server" for the ASP.NET controls!

 ASP.NET Web controls are the smallest component part  Deliver fast and easy component-oriented development process  HTML abstraction, but has server-side properties and events  Rendered as HTML (+ CSS + scripts) 14 <asp:Button runat="server" ID="btn" Text="Click me!" OnClick="btn_Click" /> Text="Click me!" OnClick="btn_Click" />

 The configuration file for ASP.NET application  Text based XML document  Web.config defines:  Connection strings to any DB used by app  Security settings and membership settings  Whether debugging is allowed 15 <configuration> </configuration> Minimal Web.config should look like this

 Steps to create a simple ASP.NET Web application: 1.Start Visual Studio 2.Create “New Web Application” 3.Add two text fields, a button and a label 4.Handle Button.Click and implement logic to sum of the values from the text fields 5.Display the results in the label 16

Live Demo

 First call to particular page 19

 Any other call after the first 20

 When requested an ASP.NET Web form is parsed by ASP.NET and converted to a tree  Also called a controls tree (XML tags are turned into a tree of controls) 21 Form PanelTextBox LabelTextBoxButton Page Head… …

 At each request to a Web Form: 1.The form is created (a page instance) 2.The VIEWSTATE is restored (the state of each control, sent from the browser) 3.The page and control events are executed 4.The VIEWSTATE is saved in a hidden field 5.The form is rendered as HTML 6.The form is unloaded (destroyed)  Important: page instances do not survive the next HTTP request! 22

1. PreInit 2. Init 3. Load (load data from DB) 4. (control events are executed here, e.g. Click ) 5. PreRender 6. Render 7. Unload 23  Web forms and controls have lifecycle events:

24

Live Demo

What is a Postback? What is a VIEWSTATE? How It Works?

 VIEWSTATE preserves the state of a Web control into a serialized, encrypted hidden field  Postback in ASP.NET means submitting a Web form to the server (i.e. HTTP POST request)  Executed when a server-side event is raised  E.g. a button is clicked or a checkbox is checked  VIEWSTATE preserves the page and controls state  Almost all control properties: color, position, width, height, etc.  The text in the control is posted with the form 27

28

Live Demo

 Provide control over many options affecting the compilation and execution of the web form  Important directives: – main directive of the page – imports a namespace into the page – attaches an assembly to the form when it is compiled – controls the ability of the forms to use cache – registers a user control to be used in a web form 31

 Defines a form-specific (.aspx file) attributes used by the ASP.NET runtime  Important attributes:  AutoEventWireup – auto-bind the controls' events to appropriate methods in the code  Culture – a culture used at page generation  UICulture – a culture for the data visualization  Language – code language (C#, VB.NET, …)  Codebehind – the code-behind file 32

 Important attributes:  Debug – whether the page is compiled with debug symbols in it  EnableSessionState – whether a session is supported  EnableViewState – whether to use "view state" or not  ErrorPage – a page to which to redirect in case of unhandled exception 33

Live Demo

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

1. Create a simple ASPX page that enters a name and prints "Hello" + name in the page. Use a TextBox + Button + Label. 2. Start Visual Studio and create new Web Forms App. Look at the files generated and tell what's purpose of each file. Explain the "code behind" model. Print "Hello, ASP.NET" from the C# code and from the aspx code. Display the current assembly location by Assembly.GetExecutingAssembly().Location. 3. Dump all the events in the page execution lifecycle using appropriate methods or event handlers. 36

 "Web Design with HTML 5, CSS 3 and JavaScript" Telerik Academy  html5course.telerik.com html5course.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com