Does that subject looks lame or what! I'm trying to stop using the “Atlas” name -- it's ASP.NET AJAX now, and getting used to the new name is a major pain in the backside. Even though the official name Jessie-James-Garett-certified name is Ajax (note the capitalization), Microsoft chose AJAX. Anyway, I hope I'll get used to it eventually.
All this does is create a global Telerik object and then attach a Samples one onto it, so that you can create subobjects yourself. Here’s how we define a class after that:
Telerik.Samples.ImageSlideShow = function(element)
A class is defined by its constructor function. Note that our class would want to call its base class’ constructor, so we use the initializeBase method that is provided by the ASP.NET AJAX component model. The last thing we need to do is register the class with the type infrastructure:
registerClass requires two parameters: the full class name and the type of the class you inherit from. It takes care to provide the initializeBase method that you saw already.
That’s all! We now have an empty control class. How do we use it? First we need to include the script file on the page. We do that by using the ASP.NET AJAX ScriptManager server control:
<atlas:ScriptManager ID="ScriptManager1" runat="server">
<atlas:ScriptReference Path="~/ImageSlideShowEmptyClass.js" />
ImageSlideShowEmptyClass.js has the definition of our class. We can then define a pageLoad global function and exercise our code there. pageLoad will be automatically called by the runtime right after initialization is complete:
var slideShow = new Telerik.Samples.ImageSlideShow($("ImageSlideShow1"))
Here's a quick preview on what we'll cover in the next posts:
- defining properties and adding property metadata by creating a type descriptor; using the type descriptor to create the component declaratively from xml-script
- implementing IDisposable and cleaning things up on page unloads and UpdatePanel refreshes
- consuming and firing events
- creating a server-side control that renders and initializes the client-side component