Hi,
I am trying to create a custom server control that contains several
dropdownlists. The control looks like this:
Dim pnlHeader As New Panel
Protected Overrides Sub RenderContents( ByVal writer as HtmlTextWriter)
pnlHeader.Rende rControl(writer )
End Sub
Public Sub Setup_Control()
Dim table As New HtmlControls.Ht mlTable
table.Attribute s.Add("style", "width:100% ")
pnlHeader.Contr ols.Add(table)
Dim row As New HtmlControls.Ht mlTableRow
Dim cellLabel As New HtmlControls.Ht mlTableCell
cellLabel.Width = "60%"
Dim lblProblems As New Label
lblProblems.ID = "lbl" & Category.Proble mTypeId
lblProblems.Tex t = "Choose Vendor for All " &
Category.Proble mType & " Problems."
cellLabel.Contr ols.Add(lblProb lems)
Dim cellDDL As New HtmlControls.Ht mlTableCell
cellDDL.Width = "30%"
Dim ddlAll As New DropDownList
ddlAll.ID = "ddlVendorForAl l" &
Category.Proble mTypeId.ToStrin g()
ddlAll.AutoPost Back = True
Common.FillList (ddlAll, HeatMapData.Get Vendors(Propert yId,
"[Choose a Vendor]"))
cellDDL.Control s.Add(ddlAll)
listDDL.Add(ddl All)
AddHandler ddlAll.Selected IndexChanged, AddressOf
ddlAll_Selected IndexChanged
Dim cellImage As New HtmlControls.Ht mlTableCell
cellImage.Width = "9%"
Dim imgExpand As New WebControls.Ima ge
imgExpand.ID = "imgExpand" &
Category.Proble mTypeId.ToStrin g()
imgExpand.Image Url = "~/images/icons/118.png"
imgExpand.ToolT ip = "View Details"
Dim imgCollapse As New WebControls.Ima ge
imgCollapse.ID = "imgCollaps e" &
Category.Proble mTypeId.ToStrin g()
imgCollapse.Ima geUrl = "~/images/icons/116.png"
imgCollapse.Too lTip = "Hide Details"
imgCollapse.Att ributes.Add("st yle", "display:no ne")
cellImage.Contr ols.Add(imgExpa nd)
cellImage.Contr ols.Add(imgColl apse)
row.Controls.Ad d(cellLabel)
row.Controls.Ad d(cellDDL)
row.Controls.Ad d(cellImage)
table.Rows.Add( row)
pnlHeader.BackC olor = Drawing.Color.F romArgb(255, 206,
204, 204)
End Sub
Protected Sub ddlAll_Selected IndexChanged(By Val sender As Object,
ByVal e As System.EventArg s)
....
End Sub
The control renders fine. The problem I am having is that the
dynamically created dropdownlist (ddlAll) does not fire the
SelectedIndexCh anged event. What am I missing?
Thanks,
Jeremy
I am trying to create a custom server control that contains several
dropdownlists. The control looks like this:
Dim pnlHeader As New Panel
Protected Overrides Sub RenderContents( ByVal writer as HtmlTextWriter)
pnlHeader.Rende rControl(writer )
End Sub
Public Sub Setup_Control()
Dim table As New HtmlControls.Ht mlTable
table.Attribute s.Add("style", "width:100% ")
pnlHeader.Contr ols.Add(table)
Dim row As New HtmlControls.Ht mlTableRow
Dim cellLabel As New HtmlControls.Ht mlTableCell
cellLabel.Width = "60%"
Dim lblProblems As New Label
lblProblems.ID = "lbl" & Category.Proble mTypeId
lblProblems.Tex t = "Choose Vendor for All " &
Category.Proble mType & " Problems."
cellLabel.Contr ols.Add(lblProb lems)
Dim cellDDL As New HtmlControls.Ht mlTableCell
cellDDL.Width = "30%"
Dim ddlAll As New DropDownList
ddlAll.ID = "ddlVendorForAl l" &
Category.Proble mTypeId.ToStrin g()
ddlAll.AutoPost Back = True
Common.FillList (ddlAll, HeatMapData.Get Vendors(Propert yId,
"[Choose a Vendor]"))
cellDDL.Control s.Add(ddlAll)
listDDL.Add(ddl All)
AddHandler ddlAll.Selected IndexChanged, AddressOf
ddlAll_Selected IndexChanged
Dim cellImage As New HtmlControls.Ht mlTableCell
cellImage.Width = "9%"
Dim imgExpand As New WebControls.Ima ge
imgExpand.ID = "imgExpand" &
Category.Proble mTypeId.ToStrin g()
imgExpand.Image Url = "~/images/icons/118.png"
imgExpand.ToolT ip = "View Details"
Dim imgCollapse As New WebControls.Ima ge
imgCollapse.ID = "imgCollaps e" &
Category.Proble mTypeId.ToStrin g()
imgCollapse.Ima geUrl = "~/images/icons/116.png"
imgCollapse.Too lTip = "Hide Details"
imgCollapse.Att ributes.Add("st yle", "display:no ne")
cellImage.Contr ols.Add(imgExpa nd)
cellImage.Contr ols.Add(imgColl apse)
row.Controls.Ad d(cellLabel)
row.Controls.Ad d(cellDDL)
row.Controls.Ad d(cellImage)
table.Rows.Add( row)
pnlHeader.BackC olor = Drawing.Color.F romArgb(255, 206,
204, 204)
End Sub
Protected Sub ddlAll_Selected IndexChanged(By Val sender As Object,
ByVal e As System.EventArg s)
....
End Sub
The control renders fine. The problem I am having is that the
dynamically created dropdownlist (ddlAll) does not fire the
SelectedIndexCh anged event. What am I missing?
Thanks,
Jeremy
Comment