Adding Button With Event Handler to RadDock

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    1 posts
    Member since:
    Oct 2012

    Posted 08 Oct 2012 Link to this post


    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?')";

    How do I wire up a simple Button inside the RadDock to an Event Handler?
  2. Slav
    Slav avatar
    1359 posts

    Posted 11 Oct 2012 Link to this post

    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,
    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.
Back to Top