在頁面上,在加載事件中,我動態地創建控件以在頁面上顯示。這一切都正常工作。我遇到的麻煩是從AJAX控件工具包中添加擴展器,特別是我試圖向按鈕控件添加圓角。沒有錯誤被拋出,但AJAX擴展功能沒有出現在顯示的頁面中。我可以通過編程方式(服務器端)將ASP.NET AJAX擴展添加到頁面嗎?
有沒有人有任何想法,我沒有做得對,或者如果它甚至有可能?
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是頁面上的一個div)
我修改了我的示例以包含我用來添加到頁面的方式。 (實際上有一個用循環構建的HTML表格,但爲簡單起見,我沒有包含它。) 這是你的意思嗎? – StingyJack 2008-10-09 12:38:20
我已經添加了控件的次數,但是*不是*控件集合的擴展器 - 它值得檢查=) – Rob 2008-10-09 12:41:45