What is it?
An extender is the same as my previous blog, but in this case it's linking the controls to the extender using server side or code behind code. Without this ability, we'd be stuck with Atlas effects on only the controls you can design.
How does it help me?
It will only help if you need to add controls dynamically. Where you can I'd still suggest to put the properties on the form itself like previously explained.
- Gives you the ability to add controls dynamically and still give them Atlas behaviors
- Extender properties can't be added after the page init procedures. Eg a button click happens after a page init, therefore you can't add extender properties in a button click.
- You must add the dynamic controls to the form before finalising your extender properties. So if the code is adding a lot of controls to a panel, you must wait until the panel is added to the form before adding the extender properties.
- Potentially adds more difficultly to debugging.
Another simple example here with an Atlas DragPanelExtender. No controls on the aspx form, and one control added dynamically to the DragPanelExtender.
- Add an atlas ScriptManager to a webform.
- Drag an atlas DragPanelExtender onto the form.
- Double click on the form to create a Page_Load method in your code behind.
- In the code behind dynamically add a panel, another panel within that panel to be the drag panel, and another control to be the content inside the main panel.
- Add these to the form.
- Now create a DragPanelProperties object and set the TargetControlID to the main panel and the DragHandleID to the header panel which is to be the draggable control.
- Link this to the control to the extender by adding the object to the TargetProperties collection.
- All done, the dynamic control will now appear with the Atlas effects also.
<%@ 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 Page_Load(object sender, EventArgs e)
private void BuildPageDynamically()
// One of 3 main panels.
Panel p = new Panel();
p.Height = 200;
p.Width = 200;
p.ID = "Panel1";
p.BorderWidth = 1;
p.BackColor = System.Drawing.Color.PaleVioletRed;
// Add a header panel to drag by.
Panel HeaderPanel = new Panel();
HeaderPanel.Height = 20;
HeaderPanel.Width = 200;
HeaderPanel.ID = "HeaderPanel1";
HeaderPanel.BorderWidth = 1;
HeaderPanel.BackColor = System.Drawing.Color.PapayaWhip;
// Add a label in the main panel.
Label l = new Label();
l.Text = "Drag me";
l.Width = 200;
// Add the main panel onto the main form
// Create a new properties for the extender.
DragPanelProperties dpp = new DragPanelProperties();
dpp.TargetControlID = p.ID;
dpp.DragHandleID = HeaderPanel.ID;
// Add the properties to the extender
<html xmlns="http://www.w3.org/1999/xhtml" >
<title>Atlas Extender Code Behind</title>
<atlas:ScriptManager ID="scriptmgr" runat= "server" />
<form id="form1" runat="server">
<cc1:DragPanelExtender ID="DragPanelExtender1" runat="server">