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.
How does it help me?
- 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.
- You can add extender properties in server side code (code behind). Very nice.
- 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.
- 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.
I’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 “<”. IntelliSense should kick in and show cc1:ConfirmButtonProperties
- 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
<%@ Page Language="C#" %>
<%@ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
protected void AtlasBtn_Click(object sender, EventArgs e)
Response.Write("Added this text through server side code now.");
<title>Atlas Extender example</title>
<atlas:ScriptManager ID="scriptmgr" runat="server" />
<form id="form1" runat="server">
<asp:Button ID="AtlasBtn" runat="server" Text="Click to add" OnClick="AtlasBtn_Click" />
<cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server">
<cc1:ConfirmButtonProperties ConfirmText="Are you really sure?" TargetControlID="AtlasBtn" />