views:

1359

answers:

3

In a page, on the load event, I am dynamically creating controls for display on the page. This is all working properly. the trouble I am having is when adding extenders from the AJAX control toolkit, specifically I am trying to add rounded corners to a button control. No errors are thrown, but the AJAX Extension functionality does not appear in the displayed page.

Does anyone have any ideas on what I am not doing correctly, or if its even possible?

Dim container As HtmlGenericControl
Dim edit As Button
Dim editRoundedCorners As AjaxControlToolkit.RoundedCornersExtender 

For each item in items
            container = New HtmlGenericControl("div")
            container.ID = "container_" & item.code

            edit = New Button()
            edit.ID = "edit_" & item.code
            edit.Text = "Edit"
            edit.Style("padding") = "0 0 0 4px"
            edit.SkinID = "smallEditButton"

            editRoundedCorners = New AjaxControlToolkit.RoundedCornersExtender()
            editRoundedCorners.BorderColor = edit.BorderColor
            editRoundedCorners.ID = edit.ID & "_RoundedCorners"
            editRoundedCorners.Corners = AjaxControlToolkit.BoxCorners.All
            editRoundedCorners.Radius = 3
            editRoundedCorners.TargetControlID = edit.ID

            container.Controls.Add(editRoundedCorners)
            container.Controls.Add(edit)
            pageContainer.Controls.Add(container)
Next

(pageContainer is a div on the page)

+2  A: 

You need to add the "editRoundedCorners" to the page, or containers, Controls collection, so try adding the line:

Controls.Add(editRoundedCorners)

just before "'add them to page control collection" as you may only be adding the edit button, whereas both are required.

Rob
I revised my example to include the means that I am using to add to the page. (There is actually an HTML table getting built with the loop, but I have not included it for simplicity.) Is this what you mean?
StingyJack
The number of times I've added the control but *not* the extender to the controls collection - it was worth checking =)
Rob
+2  A: 

I'm using C#, so I'll be using that syntax.

As Rob said, you'll need to add the Extender to the page. You can do this by:

*parentCtrl*.Controls.Add(*extendername*);

or, alternatively

*controltype* *controlname* = (*controltype*)Page.LoadControl(typeof(*controltype*), new object[]{});

If you're passing parameters on to the control, put them in the object array.

Compulsion
Hi, So you are saying that the extender control should be added to the control collection of the TargetControl? I also have found that there are no problems with other extensions (modal, etc). Its just the rounded corners.
StingyJack
+1  A: 

You cannot apply a RoundedCornersExtender to input elements such as TextBox or Buttons.

After much digging, this is the unfortunate truth.
StingyJack

related questions