Building Control Extenders using the AJAX Control Toolkit
-
Upload
sampetruda -
Category
Documents
-
view
178 -
download
0
Transcript of Building Control Extenders using the AJAX Control Toolkit
![Page 1: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/1.jpg)
Building Control Extenders using the AJAX Control
Toolkit
Adam Calderon
Application Development Practice Lead
![Page 2: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/2.jpg)
Contact Information
• More info on InterKnowlogy:www.InterKnowlogy.com
• Contact InformationE-mail: [email protected]: 760-930-0075 x274Blog: http://blogs.InterKnowlogy.com/AdamCalderon
• About Adam Calderon• Microsoft MVP – C#• Microsoft UI Server Frameworks Advisory Council• Developer / Author / Speaker / Teacher
![Page 3: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/3.jpg)
Agenda
• Overview of Toolkit• Development Features of the Toolkit• What are going to build?• Working with the
ExtenderControlBase class• Working with the BehaviorBase class• Adding Design Time support• Summary
![Page 4: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/4.jpg)
Control Toolkit Overview
• Shared source project between Microsoft and the community (www.codeplex.com)
• Contains 30+ controls that are ready to use
• Builds on ASP.NET AJAX• Provides a development framework
for building extenders• Increases developer productivity
![Page 5: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/5.jpg)
Toolkit Development Features
• Reliance on attributes to simplify development
• Rich set of .NET classes• Rich set of JavaScript classes• Support for animation• Visual Studio templates• Design Time support
![Page 6: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/6.jpg)
What are we going to build?
• Unlimited Images• Configurable
Rotation Interval• Design Time support
for adding images, setting rotation interval
Features
![Page 7: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/7.jpg)
Building Base Solution Demo
• Create a blank Solution• Add an ASP.NET AJAX Control Project• Add an ASP.NET Web Application
Project• Add AJAX Control Toolkit references
![Page 8: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/8.jpg)
ExtenderControlBase Class
• Merges the server-side experience with the client-side experience
• Builds on functionality provided by ExtenderControl in ASP.NET AJAX
• Relies on attributes to perform ScriptBehaviorDescriptor and ScriptReference assignments
![Page 9: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/9.jpg)
ExtenderControlBase Class Diagram
• Inherits from ExtenderControl• Provides support for ensuring
properties are assigned correctly
• Provides functionality for searching contained controls
• Provides functionality to set and get properties from control viewstate
• Provides support for client state
![Page 10: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/10.jpg)
Script Behavior Attributes
Attribute ScriptBehaviorDescriptor Method
ExtenderControlProperty AddProperty
ExtenderControlEvent AddEvent
ElementReference AddElementProperty
ComponentReference AddComponentProperty
ScriptBehaviorDescriptor descriptor = new ScriptBehaviorDescriptor( "ImageRotatorExtender.ImageRotator", targetControl.ClientID); descriptor.AddProperty("rotationInterval", RotationInterval);
[ExtenderControlProperty]public int RotationInterval{ get { return GetPropertyValue<int>("RotationInterval", 3); } set { SetPropertyValue<int>("RotationInterval", value); }}
Using Attributes (No Override Required)
Using ScriptBehaviorDescriptor in GetScriptDescriptors Override
![Page 11: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/11.jpg)
Script Reference Attributes
Attribute Description
ClientScriptResource Creates a ScriptReference for the specified script
RequiredScript Ensures referenced script is included
ClientCSSResource Includes a CSS file in the control
ClientScriptResource Creates a ScriptReference for the specified script
Using ScriptReference in GetScriptReferences Override
Using Attributes (No Override Required)
ScriptReference( "ImageRotatorExtender.ImageRotator.js", this.GetType().Assembly.FullName);
[ ClientScriptResource("ImageRotator.ImageRotatorBehavior", "ImageRotator.ImageRotatorBehavior.js“)] public class ImageRotatorExtender : ExtenderControlBase { ….. }
![Page 12: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/12.jpg)
ExtenderControlBase Demo
• Adding properties• Exposing properties for behavior
assignment• Dealing with property values
![Page 13: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/13.jpg)
BehaviorBase Class
• Builds upon functionality provided by the ASP.NET AJAX JavaScript classes
• Provides base services for client-side functionality including: • working with client state• asynchronous request events of the
Sys.WebForms.PageRequestManager
![Page 14: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/14.jpg)
JavaScript Classes Diagram
![Page 15: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/15.jpg)
BehaviorBase Demo
• Creating prototype class• Adding properties• Registering class
![Page 16: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/16.jpg)
Design Time Support
• New Extender Wizard in Visual Studio 2008
• Use of System.Web.UI.Design namespace designers
• Use of PersistenceMode attribute• Use of ParseChildren attribute
![Page 17: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/17.jpg)
Design Time Support Demo
• Adding Custom classes to work with Image information
• Adding designer support for adding images
• Adding attributes to enable list of images to be stored inline with the extender
![Page 18: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/18.jpg)
Summary
• Toolkit enhances development experience making hard things easier
• Rich design time support provides a better experience for consumers of your controls
• Added functionality fills the gaps of the standard ASP.NET AJAX APIs
![Page 19: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/19.jpg)
Book on ASP.NET Ajax Development
![Page 20: Building Control Extenders using the AJAX Control Toolkit](https://reader031.fdocuments.in/reader031/viewer/2022032115/55b53e5cbb61eb1c558b46a6/html5/thumbnails/20.jpg)
Contact Information
• More info on InterKnowlogy:www.InterKnowlogy.com
• Contact InformationE-mail: [email protected]: 760-930-0075 x274Blog: http://blogs.InterKnowlogy.com/AdamCalderon
• About Adam Calderon• Microsoft MVP – C#• Microsoft UI Server Frameworks Advisory Council• Developer / Author / Speaker / Teacher