Jim Fawcett CSE686 – Internet Programming Spring 2011

Slides:



Advertisements
Similar presentations
ASP.NET Arkitektur og Web Forms. Agenda – Web Forms Arkitektur for ASP.NET ( 1 del ) –Arkitekturen i korte træk –Fordele ved ASP.NET –Win Form Web.
Advertisements

Internetteknologi (ITNET2) Presentation 21: ASP.NET Advanced.
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.
ASP.NET and ADO.NET. ASP.NET Server Controls Intrinsic Controls: These controls correspond to their HTML counterparts. –Ex. Textbox, listbox, button,
COS 381 Day 23. © 2006 Pearson Addison-Wesley. All rights reserved Agenda Capstone progress report Overdue –Only received 1 out of 6 Capstone projects.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
ASP.NET Programming with C# and SQL Server First Edition
Web Forms. Agenda Web forms Web controls Code separation Dynamic compilation System.Web.UI.Page User controls.
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.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
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.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
1 ASP.NET. 2 ASP.NET Architecture ASP.NET uses the CLR to replace the existing ISAPI/ASP infrastructure of IIS with a more efficient and easier-to-use.
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.
1 Web Forms Andy Scrase.NET developer, Christchurch NZ
ASP.NET Part 4 Instructor: Charles Moen CSCI/CINF 4230.
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.
Chapter 71 Building Data-Driven ASP.NET Applications Introduction to ASP.NET By Kathleen Kalata.
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 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 application. Roadmap ASP.NET file types Bin directory Application updates Simple application from start to finish using a virtual directory Behind.
Internet Technologies and Web Application Web Services With ASP.NET Tutorial: Introduction to.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Anatomy of an ASP.NET Page. Slide 2 Compiling an ASP.NET Page An ASP.NET page is compiled when it is rendered for the first time A page is compiled to.
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.
ASP.NET 4 Unleashed Chapter 1. .aspx page: contains C# script and HTML code including tags. Listing 1.1 FirstPage.aspx.
Module 4: Creating a Web Application with Web Forms
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
Web Application Development Introduction. Lesson: Creating Web Forms What is a Web Form? Creating a Web Form with Visual Studio.NET.
Asp.NET Core Server Controls. Slide 2 Lecture Overview Understanding the types of ASP.NET controls HTML controls ASP.NET (Web) 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.
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Web Parts Overview Web parts in SharePoint 2007 “Hello World” web part Typical deployment.
Building Custom Controls with ASP.NET and the Microsoft ®.NET Framework Rames Gantanant Microsoft Regional Director, Thailand
Module 10: Data Access in ASP.NET. Overview Overview of the ASP.NET Data Access What is Data Access List of Data Source Control What is Data Bound How.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
ASP.NET Part 2 Instructor: Charles Moen CSCI/CINF 4230.
Jim Fawcett CSE686 – Internet Programming Spring 2014
Jim Fawcett CSE686 – Internet Programming Spring 2014
Current Popular IT I Pertemuan 5
Computing with C# and the .NET Framework
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
ASP.NET Forms.
Jim Fawcett CSE691 – Comparative Platforms Summer 2007
Working with ASP.NET Server Controls
Unit 7 Learning Objectives
Jim Fawcett CSE686 – Internet Programming Spring 2012
Session Variables and Post Back
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.
Web Forms, HTML, and ASP.NET
Chapter 8 User Controls.
Other Asp.Net Elements ASP.Net 2.0 – Visual Studio 2008
Active Server Pages ASP.Net
ASP.NET Application Framework
Anatomy of an ASP.NET Page
Module 10: Creating a Web Application with Web Forms
ASP.NET.
Web Development Using ASP .NET
Chapter 10 Accessing Database Files
ASP.NET and ADO.NET.
Presentation transcript:

Jim Fawcett CSE686 – Internet Programming Spring 2011 ASP.Net – Part II Jim Fawcett CSE686 – Internet Programming Spring 2011

References Pro ASP.Net 4.0 in C# 2010, MacDonald, Freeman, & Szpuszta, Apress, 2010 Programming Microsoft .Net, Jeff Prosise, Microsoft Press, 2002, Chapters 5 and 6. Essential ASP.NET with Examples in C#, Fritz Onion, Addison-Wesley, 2003 Several of the examples used here for state management were used with only minor modifications from this reference.

Topics Architecture Controls Data Binding State Management

Architecture ASP application Page Class ProcessXML_aspx ProcessXML.aspx.cs Web.config Page Class MapPath() Application ContentType Context IsPostBack Request Response Server Session Trace User … ProcessXML_aspx Page_Load(Object, System.EventArgs) Button1_Click(Object, System.EventArgs) InitializeComponent() …

Page Events public event EventHandler Init; Page_Init(object,EventArgs) public event EventHandler Load; Page_Load(object,EventArgs) public event EventHandler PreRender; Page_PreRender(object,EventArgs) public event EventHandler Unload; Page_Unload(object,Eventargs) protected virtual void OnInit(EventArgs e); protected virtual void OnLoad(EventArgs e); protected virtual void OnPreRender(EventArgs e); protected virtual void OnUnload(EventArgs e);

ASP.Net Directives @Page @Import Namespaces @Register @Implements Defines Language and Code-Behind file @Import Namespaces Equivalent to using directives @Register Registers user controls with page. Page will call render on each of its registered controls. @Implements Declares an interface this page implements @Reference Specifies a page or user control that will be compiled and linked at run-time @Assembly Links an assembly to the current page during compilation Plus more – see help documentation

Page Attribures CodeFile Inherits AutoEventWireup Debug Specifies a path to a code-behind file for the page. Used with Inherits attribute. Inherits Defines a code-behind class for the page to inherit. AutoEventWireup If true, the default, simple event handlers like Page_Load(…) are wired up automatically. Debug If true, code behind is compiled with debug symbols.

ASP Components You can create library assemblies that are available to every aspx page in your application. Compile the library dll assembly Place it in a bin directory under the application virtual directory It will then be implicitly referenced by any page that loads from the application directory You can copy over the dll with an update without stopping IIS. If you do this, the new version becomes available on the next page load.

Controls HTML Controls Examples: Web Controls Examples: HTML syntax runat=server attribute Derives from HtmlControl Instance created at server when page is constructed Examples: <form runat=server> <img runat=server> <input type=file runat=server> <input type=radio runat=server> Web Controls asp: prefix runat=server attribute Derives from WebControl Instance created at server when page is constructed Richer set of methods, properties, and events than HTML Controls Examples: <asp:TextBox id=tb1 runat=server> <asp:Button Text=“Submit” runat=server>

Web Control Catalog TextBox Label HyperLink Image CheckBox RadioButton Table – matrix addresses Panel Button ListBox DropDownList CheckBoxList RadioButtonList Repeater – HTML template DataList – HTML template DataGrid – no longer in toolbox by default, but can be added Calendar Validation Controls RequiredField RegularExpression Range Compare Custom

Data Related Controls Data Controls Validation Controls GridView DataList DataSet DetailsView FormView Repeater SqlDataSource ObjectDataSource XmlDataSource SiteMapDataSource Validation Controls RequiredFieldValidator RangeValidator RegularExpressionValidator CompareValidator CustomValidator

More Controls Navigation Controls Login Controls Webparts SiteMapPath Menu TreeView Login Controls Login LoginView PasswordRecovery LoginStatus LoginName ChangePassword Webparts WebPartManager ProxyWebPartManager WebPartZone CatalogZone DeclarativeCatalogPart PageCatalogPart ImportCatalogPart EditorZone AppearanceEditorPart BehaviorEditorPart LayoutEditorPart PropertyGrideEditorPart ConnectionsZone

User Defined Controls User controls are stored in ascx files. They contain an @control directive that plays the same role as the @Page directive for WebForms. <%@ Control classname=“UserControlCS” %> In an aspx file that uses the control: <%@ Register TagPrefix=“cse686” TagName=“IP” Src=“MyControl.ascx” %> <cse686:IP id=“myControl1” runat=“server” /> A user control may contain HTML and codebehind with methods, properties, and events. Events are declared as delegates with the event qualifier

Custom Server Controls Custom Server Controls are stored in C# files. A Server Control contains a C# class that defines the attributes: [Bindable(true)] [Category(“Appearance”)] [ToolboxData(“<{0}:NavBar runat=server></{0}:NavBar>”)] And a class NavBar : System.Web.UI.WebControls.WebControl In an aspx file that uses the control: <%@ Register TagPrefix=“cse686” assembly=“NavControl” namespace=“NavControl %> <cse686:NavBar id=“NavBar1” runat=“server” />

Data Binding Data Binding provides an abstraction for loading a control with data provided by some collection. The data is cached in the control until it is rendered on the client’s page by putting it onto the response buffer, formatted according to the control’s policy. We have already seen an example of binding an HTML table to an XML file, in Lecture #2. Binding is often used when an ASP application connects to a database through a DataReader or DataSet.

Data Binding Controls that Support Data Binding must expose: a property called DataSource a method called DataBind() The data source must provide: IEnumerable interface Example: DataSet ds = new DataSet(); ds.ReadXML(Server.MapPath(“test.xml”); ListBox1.DataSource = ds; ListBox1.DataTextField = “file”; // omit if flat ListBox1.DataBind();

Data Binding Data Binding Controls Data Sources HtmlSelect CheckBoxList DataGrid DataList Repeater DropDownList ListBox RadioButtonList Data Sources Array ArrayList HashTable Queue SortedList Stack StringCollection DataView DataTable DataSet IDataReader Classes that implement IEnumerable

State Management Adding user state inherently reduces scalability. So if you are trying to provide a resource that handles a large volume of traffic, you will want to minimize use of state. Types of state Application: Shared across all clients of this application Session: Per client state persistent over page boundaries. Requires cookies or URL mangling to manage client association. Cookie: Per client state stored on client. Clients can disable cookies. ViewState: Shared across post requests to the same page. Sent back and forth with each request.

Application State In Global.asax: (add new item/Global Application Class) void Application_Start(object src, EventArgs e) { DataSet ds = new DataSet(); // populated by clients Application[“SharedDataSet”] = ds; } In Application Page: private void Page_Load(object src, EventArgs e) { DataSet ds = (DataSet)(Application[“SharedDataSet”]); // client interacts with DataSet }

Session State By default session state is managed in the same process and application domain as the application so you can store any data in session state directly. Session state is available as a property of both Page and HttpContext classes. It is: Initialized in Global.asax Accessed in any member function of the Page. You specify whether you want session ids managed as cookies or URL mangling in the web.config file: <configuration> <system.web> <sessionState cookieless=“true” /> </system.web> </configuration>

Session State In Global.asax: void Session_Start(object src, EventArgs e) { DataSet ds = new DataSet(); // populated by clients Session[“myDataSet”] = ds; } In Application Page: private void Page_Load(object src, EventArgs e) { DataSet ds = (DataSet)(Session[“myDataSet”]); // client interacts with DataSet }

Cookies Protected void Page_Load(Object sender, EventArgs e) { int age = 0; if(Request.Cookies[“Age”] == null) HttpCookie ac = new HttpCookie(“Age”); ac.Value = ageTextBox.Text; Response.Cookies.Add(ac); age = Convert.ToInt32(ageTextBox.Text); } else { age = Convert.ToInt32(Request.Cookies[“Age”].Value); } // use age }

ViewState ViewState is used by ASP controls to transfer control state back and forth between server and client. You also can use ViewState to transfer application state: private void Page_Load(Object sender, EventArgs e) { ArrayLIst cart = (ArrayList)ViewState[“Cart”]; if(cart == null) { cart = new ArrayList(); ViewState[“Cart”] = cart; } } // use cart with: ArrayList cart = (ArrayList)ViewState[“Cart”]; cart… yada, yada, yada

End of Presentation