SlideShare a Scribd company logo
ASP.NET AJAX Component Development San Diego .NET User Group Meeting February 6, 2007 Joel Rumerman
Topics AJAX Overview ASP.NET AJAX Overview Extending ASP.NET AJAX Developing ASP.NET AJAX Components
AJAX Overview A synchronous  J avaScript  A nd  X ML The ability to execute a request to an HTTP endpoint (or SOAP) in an out-of-band fashion from a web page and receive a response and do something with that response Asynchronous : talk to end points using a request - callback pattern JavaScript : language used to execute the AJAX request and handle the response XML (XSL, XSLT) : data transfer structure for data being passed to and from the server
Other AJAX Pieces XMLHttp : browser object that provides the ability to perform asynchronous requests.  browsers implement XMLHttp object in different ways JSON : JavaScript Object Notation Defined by a BNF Used to pass data to and from the server Lighter-weight compared to XML
What is ASP.NET AJAX? A new web development technology that integrates cross-browser client script libraries with the ASP.NET 2.0 development framework Cross-browser client script libraries Object-Oriented JavaScript Framework .NET like Programming Constructs Types Inheritance Interfaces Events Standardizes Client Programming Across Browsers Server side ASP.NET features facilitate adding client behaviors to web pages  Classes contained within the System.Web.UI namespace ScriptManager, ScriptReference, ScriptManagerProxy, UpdatePanel, Timer Server code isn’t required
The State of ASP.NET AJAX  On January 23, 2007 1.0 Shipped Fully supported Microsoft product (24x7x365) for 10 years Documentation, forums, downloads, and showcase at  http://ajax.asp.net Client source code available under Microsoft Permissive License  Server source code available under Microsoft Resource License
Where is ASP.NET AJAX Going Version 2 integrates directly with Orcas Better IDE experience JavaScript Intellisense Debugging support Better design time integration More Features Client Side Data Binding Gadget Support Better Web Part support
Extending ASP.NET AJAX
Goal Create reusable custom ASP.NET AJAX Client Components and ASP.NET  Server Controls that manage those components
Types of Custom ASP.NET AJAX Client Components Components Typically non-visual Not directly associated to DOM Elements Derive from Sys.Component Behaviors Extend the behavior of an existing DOM Element Derive from Sys.UI.Behavior  Controls Represents a DOM Element as a client object Derives from Sys.UI.Control
Extending ASP.NET AJAX Process Client Development Defines something that should happen in the browser  Uses the ASP.NET AJAX prototype programming model Relies upon the ASP.NET AJAX Client Runtime Server Development Developed using .NET code  Relies upon new ASP.NET AJAX libraries to register the JavaScript that manages the client component
Steps to Create Client Components Declare namespace Declare new class Declare internal members* Define and implement properties* Define and implement methods Define events Override base class methods^ Register class with framework Declare inheritance from base class^
Steps to Create Server Control  Declare control Inherit from base class (i.e. control, label, panel, etc.) Override base methods to emit JavaScript to control client component as necessary
Developing ASP.NET AJAX Components
Steps to Develop a Component Setup the Environment Develop the client code Develop the server control Wire up the server control to the client code
Setting Up the Environment Creating an ASP.NET AJAX Enabled Project Included libraries System.Web.Extensions.dll System.Web.Extensions.Design.dll Web.Config Settings Section Groups Assembly Inclusion HttpHandlers  HttpModules
Develop the Client Code Register a Namespace Declare the Component Initialize inheritance from the base class Register the Component with the runtime Inherit from Sys.Component
DEMO Creating a New ASP.NET AJAX Component
Component’s Lifecycle An ASP.NET AJAX Component is managed by the ASP.NET AJAX runtime just like an ASP.NET Control is managed by the ASP.NET page handler Just like the ASP.NET Control, the ASP.NET AJAX Component goes through a lifecycle ASP.NET Server Control OnInit CreateChildControls PreRender Render Etc. ASP.NET AJAX Component Initialize Dispose
DEMO Adding the Initialize and Dispose Method Overrides
Registering with the Runtime Our component relies upon the ASP.NET AJAX Framework Runtime Runtime must be loaded before our component’s code is parsed Use ScriptManager to add component definition to page Guarantees that our component will be parsed after the Runtime is loaded
DEMO Registering our Component with the Runtime
Instantiating the Component Creating the component Two Ways var myComponent = Sys.Component.create( ComponentType, {id: “name”} ); var myComponent = $create( ComponentType, {id: “name”}); Both create the component, add it to the runtime’s component collection, and initialize the component. Adding it to the component’s collection ensures that the same component with the same id isn’t created more than once.
DEMO Instantiating our Component
Develop the Server Control Wire our new client component to a new server control E.g. <ASP:Label … /> <span></span>  E.g. <NewTag:OurNewComponent …/> =  <script type=“javascript>  $create(Interknowlogy.AJAX.OurNewComponent);  </script> Use ScriptManager.Registerxxx rather than Page.ClientScript.Register xxxx Ensures that the JavaScript is registered properly when the control is contained within an UpdatePanel
DEMO Create a Server Control Wired to Our New Component
Develop the Server Control Associate the Server Control to the Component’s client definition Embed the JavaScript in the DLL as a resource Load the JavaScript into the ScriptManager using a ScriptReference
DEMO Add the Client Code to the Server Control
More Client Code – Private Members and Properties Private members Use this._**** style this._enabled Private by convention, not be practice Public properties Use this.get_****, this.set_**** style this.get_enabled: function() { return this._enabled;} this.set_enabled: function(value) { this._enabled = value; } Following these conventions sets up the ability for intellisense to work properly in Oracas
DEMO Adding Private Members and Public Properties
More Client Code – Validating Parameters  Very similar to .NET parameter checking capabilities Built-in parameter validation functionality var e xception  = Function._validateParams(arguments, [{name: &quot;value&quot;, type: Boolean}]); arguments  represents the arguments of the method Array of argument description objects Name of argument (i.e. “value”) Type of argument Boolean, Function, Number, String, Sys.WebForms.PageRequestArgs,  user-defined Optional arguments may be null Exception is assigned to an error if the parameters did not validate properly
DEMO Validating Parameters
More Client Code - Events All components have eventing model built-in Add and removing events to the base class event collection this.get_events().addHandler( eventName ,  function); this.get_events().removeHandler( eventName, function); Wrap adding/removing of events in “add_ eventName ”, “remove _eventName ” methods add_enabledChange: function(handler) {…} remove_enabledChange: function(handler) {…} Again, provides ability for intellisense in Oracas
DEMO Creating Event Handlers and Wiring Them Up
DEMO A Useful Component - PostBackDisabler
Contact Info Joel Rumerman Email:  [email_address] Blog:  http:// blogs.interknowlogy.com/joelrumerman
Ad

Recommended

PPTX
Ajax control asp.net
Sireesh K
 
PPTX
Ajax control tool kit
Vidhi Patel
 
PPT
Introduction To Asp.Net Ajax
Jeff Blankenburg
 
PPT
ASP.NET AJAX Basics
petrov
 
PPTX
MVC Training Part 1
Lee Englestone
 
PPTX
MVC Training Part 2
Lee Englestone
 
PPT
ASP.NET 03 - Working With Web Server Controls
Randy Connolly
 
PPT
Web controls
Sarthak Varshney
 
PPT
Backbone js
Knoldus Inc.
 
ODP
Spray - Build RESTfull services in scala
Sandeep Purohit
 
PDF
Visual studio 2008 asp net
Portal_do_Estudante_SQL
 
PPTX
Ch 04 asp.net application
Madhuri Kavade
 
PPT
ASP.NET AJAX with Visual Studio 2008
Caleb Jenkins
 
PPTX
Using the Tooling API to Generate Apex SOAP Web Service Clients
Salesforce Developers
 
PDF
Angular2 Development for Java developers
Yakov Fain
 
PPT
Server Controls of ASP.Net
Hitesh Santani
 
PDF
Web sockets in Angular
Yakov Fain
 
PPTX
Auto fac mvc以及進階應用(一)
LearningTech
 
PPTX
Web api
udaiappa
 
PDF
Webservices in SalesForce (part 1)
Mindfire Solutions
 
PDF
React native app with type script tutorial
Katy Slemon
 
PDF
RESTful services and OAUTH protocol in IoT
Yakov Fain
 
PPTX
ASP.NET MVC Performance
rudib
 
PPTX
Web API authentication and authorization
Chalermpon Areepong
 
PDF
Angular - Chapter 1 - Introduction
WebStackAcademy
 
PPTX
ASP.NET Page Life Cycle
Abhishek Sur
 
PPSX
13 asp.net session19
Vivek Singh Chandel
 
PPT
SynapseIndia dotnet client library Development
Synapseindiappsdevelopment
 
PPTX
Ajax and ASP.NET AJAX
Julie Iskander
 

More Related Content

What's hot (20)

PPT
Backbone js
Knoldus Inc.
 
ODP
Spray - Build RESTfull services in scala
Sandeep Purohit
 
PDF
Visual studio 2008 asp net
Portal_do_Estudante_SQL
 
PPTX
Ch 04 asp.net application
Madhuri Kavade
 
PPT
ASP.NET AJAX with Visual Studio 2008
Caleb Jenkins
 
PPTX
Using the Tooling API to Generate Apex SOAP Web Service Clients
Salesforce Developers
 
PDF
Angular2 Development for Java developers
Yakov Fain
 
PPT
Server Controls of ASP.Net
Hitesh Santani
 
PDF
Web sockets in Angular
Yakov Fain
 
PPTX
Auto fac mvc以及進階應用(一)
LearningTech
 
PPTX
Web api
udaiappa
 
PDF
Webservices in SalesForce (part 1)
Mindfire Solutions
 
PDF
React native app with type script tutorial
Katy Slemon
 
PDF
RESTful services and OAUTH protocol in IoT
Yakov Fain
 
PPTX
ASP.NET MVC Performance
rudib
 
PPTX
Web API authentication and authorization
Chalermpon Areepong
 
PDF
Angular - Chapter 1 - Introduction
WebStackAcademy
 
PPTX
ASP.NET Page Life Cycle
Abhishek Sur
 
PPSX
13 asp.net session19
Vivek Singh Chandel
 
Backbone js
Knoldus Inc.
 
Spray - Build RESTfull services in scala
Sandeep Purohit
 
Visual studio 2008 asp net
Portal_do_Estudante_SQL
 
Ch 04 asp.net application
Madhuri Kavade
 
ASP.NET AJAX with Visual Studio 2008
Caleb Jenkins
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Salesforce Developers
 
Angular2 Development for Java developers
Yakov Fain
 
Server Controls of ASP.Net
Hitesh Santani
 
Web sockets in Angular
Yakov Fain
 
Auto fac mvc以及進階應用(一)
LearningTech
 
Web api
udaiappa
 
Webservices in SalesForce (part 1)
Mindfire Solutions
 
React native app with type script tutorial
Katy Slemon
 
RESTful services and OAUTH protocol in IoT
Yakov Fain
 
ASP.NET MVC Performance
rudib
 
Web API authentication and authorization
Chalermpon Areepong
 
Angular - Chapter 1 - Introduction
WebStackAcademy
 
ASP.NET Page Life Cycle
Abhishek Sur
 
13 asp.net session19
Vivek Singh Chandel
 

Similar to Asp.Net Ajax Component Development (20)

PPT
SynapseIndia dotnet client library Development
Synapseindiappsdevelopment
 
PPTX
Ajax and ASP.NET AJAX
Julie Iskander
 
PPT
SynapseIndia asp.net2.0 ajax Development
Synapseindiappsdevelopment
 
PPT
Ajaxppt
Iblesoft
 
PPTX
Walther Ajax4
rsnarayanan
 
PPTX
New microsoft office power point presentation
teach4uin
 
PPTX
AJAX Patterns with ASP.NET
goodfriday
 
PPT
SynapseIndia dotnet development ajax client library
Synapseindiappsdevelopment
 
PPT
Synapseindia dot net development web applications with ajax
Synapseindiappsdevelopment
 
PPTX
Walther Aspnet4
rsnarayanan
 
PPT
Developing an ASP.NET Web Application
Rishi Kothari
 
PPT
How to develop asp web applications
Deepankar Pathak
 
PPS
Web 2.0 Mimbar Ilmiah
Soetam Rizky
 
PPTX
Ajax
Gayathri Ganesh
 
PDF
Integrating ASP.NET AJAX with SharePoint
Rob Windsor
 
PPT
Intro To Asp Net And Web Forms
SAMIR BHOGAYTA
 
PDF
AJAX in ASP.NET
James Crowley
 
PPTX
Ajax technology
Safal Agrawal
 
PPT
Asp.net server controls
Raed Aldahdooh
 
PPT
Building intranet applications with ASP.NET AJAX and jQuery
Alek Davis
 
SynapseIndia dotnet client library Development
Synapseindiappsdevelopment
 
Ajax and ASP.NET AJAX
Julie Iskander
 
SynapseIndia asp.net2.0 ajax Development
Synapseindiappsdevelopment
 
Ajaxppt
Iblesoft
 
Walther Ajax4
rsnarayanan
 
New microsoft office power point presentation
teach4uin
 
AJAX Patterns with ASP.NET
goodfriday
 
SynapseIndia dotnet development ajax client library
Synapseindiappsdevelopment
 
Synapseindia dot net development web applications with ajax
Synapseindiappsdevelopment
 
Walther Aspnet4
rsnarayanan
 
Developing an ASP.NET Web Application
Rishi Kothari
 
How to develop asp web applications
Deepankar Pathak
 
Web 2.0 Mimbar Ilmiah
Soetam Rizky
 
Integrating ASP.NET AJAX with SharePoint
Rob Windsor
 
Intro To Asp Net And Web Forms
SAMIR BHOGAYTA
 
AJAX in ASP.NET
James Crowley
 
Ajax technology
Safal Agrawal
 
Asp.net server controls
Raed Aldahdooh
 
Building intranet applications with ASP.NET AJAX and jQuery
Alek Davis
 
Ad

More from Chui-Wen Chiu (20)

ODP
Dynamic Python
Chui-Wen Chiu
 
ODP
Pythonpresent
Chui-Wen Chiu
 
ODP
Introduce Django
Chui-Wen Chiu
 
PDF
移動內存算法
Chui-Wen Chiu
 
PPT
墾丁 更新版
Chui-Wen Chiu
 
PPT
墾丁 更新版2
Chui-Wen Chiu
 
PDF
Bw1096
Chui-Wen Chiu
 
PPT
高雄新地標 統一夢世代
Chui-Wen Chiu
 
PDF
Borland傳奇
Chui-Wen Chiu
 
PDF
Python 庫簡介
Chui-Wen Chiu
 
PDF
Asp.Net Mvc 1.0
Chui-Wen Chiu
 
PDF
天下第一 夜市總冠軍
Chui-Wen Chiu
 
PPT
下班就跑是富有哲學道理1
Chui-Wen Chiu
 
PDF
認識腸病毒
Chui-Wen Chiu
 
PDF
排隊的店
Chui-Wen Chiu
 
PPS
柬埔寨鄉村婚禮
Chui-Wen Chiu
 
PPS
新 創 意
Chui-Wen Chiu
 
PPT
挖好屬於自己的井
Chui-Wen Chiu
 
PPS
Why The Us Wants War 080702
Chui-Wen Chiu
 
PPS
你今天的選擇是什麼?
Chui-Wen Chiu
 
Dynamic Python
Chui-Wen Chiu
 
Pythonpresent
Chui-Wen Chiu
 
Introduce Django
Chui-Wen Chiu
 
移動內存算法
Chui-Wen Chiu
 
墾丁 更新版
Chui-Wen Chiu
 
墾丁 更新版2
Chui-Wen Chiu
 
高雄新地標 統一夢世代
Chui-Wen Chiu
 
Borland傳奇
Chui-Wen Chiu
 
Python 庫簡介
Chui-Wen Chiu
 
Asp.Net Mvc 1.0
Chui-Wen Chiu
 
天下第一 夜市總冠軍
Chui-Wen Chiu
 
下班就跑是富有哲學道理1
Chui-Wen Chiu
 
認識腸病毒
Chui-Wen Chiu
 
排隊的店
Chui-Wen Chiu
 
柬埔寨鄉村婚禮
Chui-Wen Chiu
 
新 創 意
Chui-Wen Chiu
 
挖好屬於自己的井
Chui-Wen Chiu
 
Why The Us Wants War 080702
Chui-Wen Chiu
 
你今天的選擇是什麼?
Chui-Wen Chiu
 
Ad

Asp.Net Ajax Component Development

  • 1. ASP.NET AJAX Component Development San Diego .NET User Group Meeting February 6, 2007 Joel Rumerman
  • 2. Topics AJAX Overview ASP.NET AJAX Overview Extending ASP.NET AJAX Developing ASP.NET AJAX Components
  • 3. AJAX Overview A synchronous J avaScript A nd X ML The ability to execute a request to an HTTP endpoint (or SOAP) in an out-of-band fashion from a web page and receive a response and do something with that response Asynchronous : talk to end points using a request - callback pattern JavaScript : language used to execute the AJAX request and handle the response XML (XSL, XSLT) : data transfer structure for data being passed to and from the server
  • 4. Other AJAX Pieces XMLHttp : browser object that provides the ability to perform asynchronous requests. browsers implement XMLHttp object in different ways JSON : JavaScript Object Notation Defined by a BNF Used to pass data to and from the server Lighter-weight compared to XML
  • 5. What is ASP.NET AJAX? A new web development technology that integrates cross-browser client script libraries with the ASP.NET 2.0 development framework Cross-browser client script libraries Object-Oriented JavaScript Framework .NET like Programming Constructs Types Inheritance Interfaces Events Standardizes Client Programming Across Browsers Server side ASP.NET features facilitate adding client behaviors to web pages Classes contained within the System.Web.UI namespace ScriptManager, ScriptReference, ScriptManagerProxy, UpdatePanel, Timer Server code isn’t required
  • 6. The State of ASP.NET AJAX On January 23, 2007 1.0 Shipped Fully supported Microsoft product (24x7x365) for 10 years Documentation, forums, downloads, and showcase at http://ajax.asp.net Client source code available under Microsoft Permissive License Server source code available under Microsoft Resource License
  • 7. Where is ASP.NET AJAX Going Version 2 integrates directly with Orcas Better IDE experience JavaScript Intellisense Debugging support Better design time integration More Features Client Side Data Binding Gadget Support Better Web Part support
  • 9. Goal Create reusable custom ASP.NET AJAX Client Components and ASP.NET Server Controls that manage those components
  • 10. Types of Custom ASP.NET AJAX Client Components Components Typically non-visual Not directly associated to DOM Elements Derive from Sys.Component Behaviors Extend the behavior of an existing DOM Element Derive from Sys.UI.Behavior Controls Represents a DOM Element as a client object Derives from Sys.UI.Control
  • 11. Extending ASP.NET AJAX Process Client Development Defines something that should happen in the browser Uses the ASP.NET AJAX prototype programming model Relies upon the ASP.NET AJAX Client Runtime Server Development Developed using .NET code Relies upon new ASP.NET AJAX libraries to register the JavaScript that manages the client component
  • 12. Steps to Create Client Components Declare namespace Declare new class Declare internal members* Define and implement properties* Define and implement methods Define events Override base class methods^ Register class with framework Declare inheritance from base class^
  • 13. Steps to Create Server Control Declare control Inherit from base class (i.e. control, label, panel, etc.) Override base methods to emit JavaScript to control client component as necessary
  • 15. Steps to Develop a Component Setup the Environment Develop the client code Develop the server control Wire up the server control to the client code
  • 16. Setting Up the Environment Creating an ASP.NET AJAX Enabled Project Included libraries System.Web.Extensions.dll System.Web.Extensions.Design.dll Web.Config Settings Section Groups Assembly Inclusion HttpHandlers HttpModules
  • 17. Develop the Client Code Register a Namespace Declare the Component Initialize inheritance from the base class Register the Component with the runtime Inherit from Sys.Component
  • 18. DEMO Creating a New ASP.NET AJAX Component
  • 19. Component’s Lifecycle An ASP.NET AJAX Component is managed by the ASP.NET AJAX runtime just like an ASP.NET Control is managed by the ASP.NET page handler Just like the ASP.NET Control, the ASP.NET AJAX Component goes through a lifecycle ASP.NET Server Control OnInit CreateChildControls PreRender Render Etc. ASP.NET AJAX Component Initialize Dispose
  • 20. DEMO Adding the Initialize and Dispose Method Overrides
  • 21. Registering with the Runtime Our component relies upon the ASP.NET AJAX Framework Runtime Runtime must be loaded before our component’s code is parsed Use ScriptManager to add component definition to page Guarantees that our component will be parsed after the Runtime is loaded
  • 22. DEMO Registering our Component with the Runtime
  • 23. Instantiating the Component Creating the component Two Ways var myComponent = Sys.Component.create( ComponentType, {id: “name”} ); var myComponent = $create( ComponentType, {id: “name”}); Both create the component, add it to the runtime’s component collection, and initialize the component. Adding it to the component’s collection ensures that the same component with the same id isn’t created more than once.
  • 25. Develop the Server Control Wire our new client component to a new server control E.g. <ASP:Label … /> <span></span> E.g. <NewTag:OurNewComponent …/> = <script type=“javascript> $create(Interknowlogy.AJAX.OurNewComponent); </script> Use ScriptManager.Registerxxx rather than Page.ClientScript.Register xxxx Ensures that the JavaScript is registered properly when the control is contained within an UpdatePanel
  • 26. DEMO Create a Server Control Wired to Our New Component
  • 27. Develop the Server Control Associate the Server Control to the Component’s client definition Embed the JavaScript in the DLL as a resource Load the JavaScript into the ScriptManager using a ScriptReference
  • 28. DEMO Add the Client Code to the Server Control
  • 29. More Client Code – Private Members and Properties Private members Use this._**** style this._enabled Private by convention, not be practice Public properties Use this.get_****, this.set_**** style this.get_enabled: function() { return this._enabled;} this.set_enabled: function(value) { this._enabled = value; } Following these conventions sets up the ability for intellisense to work properly in Oracas
  • 30. DEMO Adding Private Members and Public Properties
  • 31. More Client Code – Validating Parameters Very similar to .NET parameter checking capabilities Built-in parameter validation functionality var e xception = Function._validateParams(arguments, [{name: &quot;value&quot;, type: Boolean}]); arguments represents the arguments of the method Array of argument description objects Name of argument (i.e. “value”) Type of argument Boolean, Function, Number, String, Sys.WebForms.PageRequestArgs, user-defined Optional arguments may be null Exception is assigned to an error if the parameters did not validate properly
  • 33. More Client Code - Events All components have eventing model built-in Add and removing events to the base class event collection this.get_events().addHandler( eventName , function); this.get_events().removeHandler( eventName, function); Wrap adding/removing of events in “add_ eventName ”, “remove _eventName ” methods add_enabledChange: function(handler) {…} remove_enabledChange: function(handler) {…} Again, provides ability for intellisense in Oracas
  • 34. DEMO Creating Event Handlers and Wiring Them Up
  • 35. DEMO A Useful Component - PostBackDisabler
  • 36. Contact Info Joel Rumerman Email: [email_address] Blog: http:// blogs.interknowlogy.com/joelrumerman

Editor's Notes

  • #22: Add the reference to the JavaScript class normally and show the error message that occurs. Then switch to the ScriptManager
  • #24: create