Web Forms. Agenda Web forms Web controls Code separation Dynamic compilation System.Web.UI.Page User controls.

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

IT533 Lectures Validation Controls, User Controls, Master Pages.
IT533 Lecture ASP.NET Controls. Installations Microsoft® SQL Server® 2008 Express.
11 ASP.NET Slides based off:. 22 B ACKGROUND - W EB A RCHITECTURE Web Server PC/Mac/Unix/... + Browser Client Server Request:
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
Anatomy of an ASP.NET Page. Slide 2 My Version of the Big Picture (1) ASP Worker (Engine) Your application Runs Server Other applications User 1User 2.
web controls  standard controls  validation controls  rich controls.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
ASP.NET Programming with C# and SQL Server First Edition
CST JavaScript Validating Form Data with JavaScript.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
ASP.Net, Web Forms and Web Controls 1 Outline Introduction Simple HTTP Transaction System Architecture Creating and Running a Simple Web Form Example Web.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Server-side Programming using ASP.NET Web Forms Yingcai Xiao.
JavaScript & jQuery the missing manual Chapter 11
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Chapter 3 Using Validation Controls. What is a Validation Control? A control that validates the value in another control Renders as an HTML tag with an.
1 Presented by Bikash Shrestha. 2 What is ASP.NET or ASP+? ASP.NET/ASP+ is a programming framework built on the common language runtime that can be used.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Object-Oriented Application Development Using VB.NET 1 Chapter 12 Web Forms, HTML, and ASP.NET.
HTML, GUI, ASP.NET Rina Zviel-Girshin Lecture 2
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
An Introduction to ASP.NET Ed Dunhill blogs.msdn.com/edunhill SLIDE7.
Telerik Software Academy ASP.NET Web Forms Data Validation, Data Validators, Validation Groups Telerik Software Academy
Overview of Previous Lesson(s) Over View  Server controls are small building blocks of the graphical user interface, which includes  Text boxes  Buttons.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Beginning Web Site Development Module 1 – Dynamic Web Site Development Fundamentals of building dynamic Web sites with ASP.NET 2.0 and C# Version.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 4-1 of…
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
INSPIRING CREATIVE AND INNOVATIVE MINDS Module 4: Adding Code to a Microsoft ASP.NET Web Form Implementing Code-Behind Pages Adding Event Procedures to.
ASP.Net, Web Forms and Web Controls 1 Outline Web Controls Text and Graphics Controls AdRotator Control Validation Controls.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
ASP.NET Web Server Controls Basic Web Server Controls.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
ASP.NET Controls. Slide 2 Lecture Overview Identify the types of controls supported by ASP.NET and the differences between them.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Tracing 1www.tech.findforinfo.com. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Introduction to ASP.NET T.Ahlam Algharasi. The Visual Studio IDE Start page 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Unit 3: Adding Code to a Microsoft ASP.NET Web Form.
Overview of Previous Lesson(s) Over View  SDI programs  The Application Wizard can generate single-document interface (SDI) applications that work.
Module 4: Creating a Microsoft ASP.NET Web Form. Overview Creating Web Forms Using Server Controls.
PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.
Christopher M. Pascucci.NET Programming CodeBehind.
TRAINING SESSIONS.NET Controls.  Standard Controls  Label  Textbox  Checkbox  Button, Image Button, Image control  Radio Button  Literal  Hyperlink.
ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) controls.
1 10/19/05CS360 Windows Programming ASP.NET. 2 10/19/05CS360 Windows Programming ASP.NET  ASP.NET works on top of the HTTP protocol  Takes advantage.
1111 Creating ASPX Controls Programatically Objectives You will be able to Dynamically add controls to a page. Dynamically alter properties of controls.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Svetlin Nakov Telerik Corporation
Building Custom Controls with ASP.NET and the Microsoft ®.NET Framework Rames Gantanant Microsoft Regional Director, Thailand
Beginning ASP.NET in C# and VB Chapter 9
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.
Sergey Sidorov PhD student, computer software chair Computer Science department.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
1 Introducing Web Developer Tools Rapid application development tools ASP.NET-compatible web editors –Visual Studio.NET Professional Edition –Visual Studio.
ASP.NET Part 2 Instructor: Charles Moen CSCI/CINF 4230.
Validation Controls Assist your users with providing the correct type of input for your application Assist your users with providing the correct type of.
ASP.NET Forms.
Web Application Web Application are programs that can be executed either on a Web server or in a Web browser. An Online store accessed through a browser.
Anatomy of an ASP.NET Page
ASP.NET.
Web Development Using ASP .NET
Server Controls Validation Controls
Presentation transcript:

Web Forms

Agenda Web forms Web controls Code separation Dynamic compilation System.Web.UI.Page User controls

HTML Form (Calc.html) +

ASP Form (Calc.asp) "/> + " /> <% If Request ("op1") <> "" And Request ("op2") <> "" Then a = CInt (Request ("op1")) b = CInt (Request ("op2")) Response.Write (CStr (a + b)) End If %>

Web Form (Calc.aspx) + void OnAdd (Object sender, EventArgs e) { int a = Convert.ToInt32 (op1.Text); int b = Convert.ToInt32 (op2.Text); Sum.Text = (a + b).ToString (); }

ASP.NET Web Forms

Web Controls Approximately 80 in all ~30 carried forward from ASP.NET 1.x ~50 new controls in ASP.NET 2.0 Rich programming model that permits difficult UIs (such as menus and tree views) to be encapsulated in easy-to-use classes Open architecture that enables developers to write custom controls of their own

“Simple” Controls NameDescription LabelRenders programmable HTML text TextBoxRenders programmable HTML text boxes HyperLinkRenders programmable HTML hyperlinks CheckBoxRenders programmable HTML check boxes RadioButtonRenders programmable HTML radio buttons ImageRenders programmable static images

“Simple” Controls, Cont. NameDescription TableRenders programmable HTML tables PanelProvides container for grouping other controls PlaceHolderServes as placeholder for adding controls at run-time HiddenFieldRenders hidden fields ( ) ImageMapRenders programmable HTML image maps FileUploadProvides UI for uploading files

Button Controls NameDescription ButtonRenders push button that posts back and fires Click event when clicked LinkButtonRenders hyperlink that posts back and fires Click event when clicked ImageButtonRenders image that posts back and fires Click event when clicked

Using the TextBox, Label, and Button Controls

List Controls NameDescription ListBoxRenders progammable HTML list boxes DropDownListRenders programmable HTML drop-down lists RadioButtonListRenders programmable groups of HTML radio buttons CheckBoxListRenders programmable groups of HTML check boxes BulletedListRenders programmable bulleted lists

Using DropDownList

Validation Controls NameDescription CompareValidatorCompares an input to another value CustomValidator RangeValidator RegularExpressionValidator RequiredFieldValidator ValidationSummary Validates input using an algorithm you supply Verifies that an input falls within a specified range Validates input using a regular expression Verifies that an input field isn't blank Displays a summary of validation errors

Input Validation

Code Separation Web forms support two* coding models: Code-inline - Markup and code in ASPX Code-behind - Markup in ASPX, code in CS/VB Visual Studio 2005 supports both models No difference in performance * Not including code-behind 1.0, which is deprecated in ASP.NET 2.0

Code-Inline + void OnAdd (Object sender, EventArgs e) { int a = Convert.ToInt32 (op1.Text); int b = Convert.ToInt32 (op2.Text); Sum.Text = (a + b).ToString (); } Calc.aspx

Code-Behind + Calc.aspx Corresponding source code file Class name in source code file

Code-Behind, Cont. Calc.aspx.cs using System; using System.Web;... public partial class Calc_aspx { void OnAdd (Object sender, EventArgs e) { int a = Convert.ToInt32 (op1.Text); int b = Convert.ToInt32 (op2.Text); Sum.Text = (a + b).ToString (); } Partial class representing this page (derives from System.Web.UI.Page)

Dynamic Page Compilation Parser DLL HTTP RequestHTTP Response Compiler Once compiled, assembly reused in subsequent requests public partial class Calc_aspx : System.Web.UI.Page,... {... } public partial class Calc_aspx : System.Web.UI.Page,... {... } ASPX public partial class Calc_aspx { // Your code } public partial class Calc_aspx { // Your code } Parser generates partial class derived from Page Calc.aspx.cs a0b1c3d4.cs Source code files passed to compiler Compiler produces assembly containing Page-derived class

Precompilation Applications can be precompiled to avoid first-access delays (new in ASP.NET 2.0)

System.Web.UI.Page Base class for pages; container for controls Your code executes in context of a Page- derived class, providing intrinsic access to Page members (e.g., Request & Response) Parser adds useful properties of its own to Page- derived classes (e.g., Profile & Resources) Page objects fire events that you can handle by implementing specially named methods Page lifetime is one request

Key Page Properties NameDescription CacheProvides access to the application cache ControlsProvides access to the page’s controls IsPostBackTrue if page is executing due to a postback RequestEncapsulates the current HTTP request ResponseEncapsulates the outgoing HTTP response SessionProvides access to session state Type Cache ControlCollection Boolean HttpRequest HttpResponse HttpSessionState UserProvides information about requestor’s identityIPrincipal MasterProvides programmatic access to master pageMasterPage

Using Page Properties if (!String.IsNullOrEmpty (Request["ItemID"])) { Response.Write (Request["ItemID"]); } Page.Request property refers to HttpRequest object representing the request Page.Response property refers to HttpResponse object representing the response

The Page_Load Method If present, called automatically in every request when Page object fires Load event Called early in page's lifetime Controls have been created and initialized No rendering has been done (yet) Perfect place to initialize controls programmatically and to bind controls to data sources

Page_Load Example... void Page_Load (Object sender, EventArgs e) { if (!IsPostBack) { MyDropDownList.Items.Add ("Item 1"); MyDropDownList.Items.Add ("Item 2"); MyDropDownList.Items.Add ("Item 3"); } No need to repopulate list when a postback occurs

Page Directives PageDefines general attributes and compilation settings for ASPX ControlDefines general attributes and compilation settings for ASCX Reference Imports a namespace Imports an assembly Registers user controls and custom controls in Web forms Provides declarative control over ASP.NET’s page output cache Adds a reference to an external ASPX or ASCX ImplementsIdentifies an interface implemented by a Web page

@ Page Example Default language Enable tracing

Page Attributes AttributeDescription ClassNameSpecifes name of code-behind class CompileWithIdentifies file containing code-behind class Culture, UICultureSpecifies culture for content localization (e.g., "en-us") DebugEnables and disables debug symbols (default=false) ErrorPageDesignates error page shown if unhandled execption occurs LanguageSpecifies language used for inline code ( ) TraceEnables and disables trace output (default=false) MasterPageFileDesignates the page's master page (if any)

User Controls Reusable chunks of HTML and code packaged in ASCX files Registered in ASPX files Register Declared in ASPX files with tag prefixes and tag names specified Register Great for replicating UI elements that appear multiple times on a given page (or separate pages)

User Controls

© Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.