This is a migrated thread and some comments may be shown as answers.

Adding Button With Event Handler to RadDock

1 Answer 80 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 08 Oct 2012, 08:48 PM
Hello,

I've search high and low for help on what I am trying to do, which seems pretty simple.

Basically, I want to create a number of RadDocks depending upon how many rows I have in a table which holds photos and data associated with them.  I am trying to add a few buttons to the RadDock that will do stuff, like delete a photo.

Here is what I have so far:

DataTable dtPhotos = GetAllByGalleryID(ID);
 
        if (dtPhotos.Rows.Count > 0)
        {
            foreach (DataRow dr in dtPhotos.Rows)
            {
                RadDock dock = new RadDock();
                dock.ID = "rd" + dr["ID"].ToString();
                dock.Title = "<div style=\"position:relative; top:7px; height:70px;\"><img class=\"galleryPhoto\" src=\"/properties/images/" + dr["ImgName"].ToString() + "\" /></div>";
                dock.EnableDrag = true;
                dock.DockMode = DockMode.Docked;
                dock.UniqueName = Guid.NewGuid().ToString();
                dock.EnableEmbeddedSkins = false;
                dock.Width = Unit.Pixel(100);
                dock.Height = Unit.Pixel(75);
                dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.Close;
                 
                dock.ContentContainer.CssClass = "photoButtons";
 
                Button delete = new Button();
                delete.Text = "Delete";
                delete.CssClass = "deleteButton";
 
                delete.Command += new DockCommandEventHandler(DeletePhoto);
                delete.CommandArgument = dr["ID"].ToString();
                delete.CommandName = "DeletePhoto";
                delete.OnClientClick = "return confirm('Are you sure you want to delete this photo?')";
 
                dock.ContentContainer.Controls.Add(delete);
 
                RadDockLayout1.Controls.Add(dock);
                dock.Dock(rdz1);
            }
        }


How do I wire up a simple Button inside the RadDock to an Event Handler?

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 11 Oct 2012, 10:48 AM
Hello Andrew,

Please verify if the RadDock controls are created on Page_Init. Also, if the docks are recreated after the postback, you should attach the button's event handler again.

Kind regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Dock
Asked by
Andrew
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or