Mostly I'll be blogging about Atlas features and examples, but will touch upon many current .net topics and no doubt some .net 3.0 topics as it draws closer.

Monday, August 21, 2006

Understanding Atlas Extenders

I'm not here to offer a brilliant new view on what an Extender is, but I feel my lack of higher education sometimes leaves me scratching my heads on Microsoft’s explanation of their good work, so I’m here to give an easy example of what an Atlas extender does for you.

What is it?.net has a great feature in extensibility. What is this? It means that if you write a new effect you can implement it on controls that don't have that functionality. The best example in winforms is the ToolTip. Before you drop a ToolTip on a form, you have no way of having hints, but once you've dropped one on a form, all your controls suddenly have a "ToolTip on toolTip1" property where you can add a hint.

An Atlas extender does a similar thing for web controls. It adds properties onto your web controls, to allow special AJAX or javascript effects without needing inheritance or anything complex to work.

How does it help me?Generally Atlas extenders are at their most useful when there is a nice javascript feature you have, but you want to attach it to your asp.net web controls. Rather than inheriting controls to add javascript niceness, you simply write an extender and use it on what controls you want to.

Pros?

There is nothing stopping you writing your own, but Microsoft has already gathered over 20 different extenders written by various authors. This is available for download in the Atlas toolkit http://atlas.asp.net/atlastoolkit/.This alone makes Atlas a compelling argument. Imagine that every decent extender that gets written gets added to the Atlas toolkit. By this time next year we could have 100 controls, which any user can access by simply downloading the toolkit.

After writing the extender, you can get javascript features in your web controls without writing a line of javascript code. This is nice as feature rich controls come without writing complex javascript code in your web form. The less code on the main page the better.

Another nice feature is you can see which Atlas extenders have been added to your web control in the Properties section. Compare this with trying to dig through javascript to see which control a certain web control that function effects and you’ll realise the Atlas extender way is much neater.

You can add extender properties in server side code (code behind). Very nice.

Cons?

I’m not an expert here, but it seems to me that as the toolkit grows, so will the size of the included toolkit dll, and therefore slow down initial page loads at a new site. This of course isn’t a downside of extenders, but the toolkit itself.

Also the extenders don’t work on html controls like a div (from what I’ve seen), so you’re stuck using the asp version of that control, which can make it harder to get extra javascript functionality sometimes.

From what I’ve seen you can’t add the extender properties to a control in the design view, but once they’re added you can see them there. (at least this isn't working on my Web Developer Express)

On the other hand you can't see the extender properties in the source view.

ExampleI’ll give a simple example here, because I’ll probably go through a lot of these controls in more detail later on. For now I’ll show the simplest example. It will extend an asp:Button to include a confirmation dialog using the ConfirmButtonExtender:

Add an Atlas ScriptManager to the form.

Drag a ConfirmButtonExtender onto a web form.

Dragging this adds a simple extender tag. All extender tags have a list of property tags within them to attach an extender to a control and give it other properties.

Drag an asp:Button onto the web form. Call it “AtlasBtn”.

Goto the Source view and find the ConfirmButtonExtender.

Start adding a new tag in the middle of that tag by pressing “

Add properties in there for ConfirmText (like "Are you really sure?") and TargetControlID="AtlasBtn".

That’s all there is to it. Now when the user clicks on that button, the server side code on AtlasBtn will only execute once the user confirms the dialog, otherwise nothing will happen. Note also that when clicking on AtlasBtn in the Design view now, the properties show the Atlas Extender

I stay around forabout 30 more minutes taking bits of film then head home. After she closes her eyes, I slip a blindfold on her and tell her not tomove.teen camping sex storiesinterracial wife storiesgay teen male sex storiesboy interracial storiesillustrated erotic storiesI stay around forabout 30 more minutes taking bits of film then head home. After she closes her eyes, I slip a blindfold on her and tell her not tomove.