danabnormal
Technical User
So, thanks to your help I managed to find my dynamically created controls for placing even more gumpf inside them.
My app presents various options within a listbox, and the user chooses which options they would like to view. The idea is then that a suitable table is generated, and these options are then placed into each cell for viewing. So....
This is called by my form handler and is passed the number of reports that have been requested. This works cool, and generates the following HTML...
So far so groovy.
The form handler then goes through to locate each dashPlace control to place the data inside it. The following code locates them and is msgboxing the control ID name as proof that it finds the controls....
I then get a series of MsgBoxes listing each name. Excellent! However, if I uncomment the ctl.Controls.Add(myPart) line, the HTML resulting HTML is...
....which just confuses me. The idea is that the dashPlace controls are used as a placemark for each control, yet it is only chucking them in the last DIV. I have also otried PlaceMark controls etc and get the same thing so its obviously something fundamental I'm getting wrong. What confuses me is that I would assume if the preceeding MsgBox command is returning the ID "dashPlace1", I would assume that I am working with a different control!
Any help, as always, most appreciated chaps!
My app presents various options within a listbox, and the user chooses which options they would like to view. The idea is then that a suitable table is generated, and these options are then placed into each cell for viewing. So....
Code:
Function drawTable(ByVal numCharts)
Dim tbl2 As New Table
tbl2.ID = "PortletDataTable"
Select Case numCharts
Case 1
Dim tr2 As New TableRow
Dim tc2 As New TableCell
Dim myPlc As New PlaceHolder
Dim myDiv As New HtmlGenericControl("div")
myDiv.ID = "dashPlace1"
tc2.Controls.Add(myDiv)
tr2.Cells.Add(tc2)
tbl2.Rows.Add(tr2)
Case Else
For a = 1 To numCharts
Dim tr2 As New TableRow
Dim tc3 As New TableCell
Dim tc2 As New TableCell
Dim myPlc As New PlaceHolder
Dim myDiv As New HtmlGenericControl("div")
Dim myDiv2 As New HtmlGenericControl("div")
tc2.Width = Unit.Percentage(33)
tc3.Width = Unit.Percentage(33)
myDiv.ID = "dashPlace" & a
myDiv2.ID = "dashPlace" & a + 1
tc2.Controls.Add(myDiv)
tc3.Controls.Add(myDiv2)
tr2.Cells.Add(tc2)
tr2.Cells.Add(tc3)
tbl2.Rows.Add(tr2)
a = a + 1
Next
End Select
drawTable = tbl2
End Function
This is called by my form handler and is passed the number of reports that have been requested. This works cool, and generates the following HTML...
Code:
<table id="PortletDataTable" border="0">
<tr>
<td style="width:33%;"><div id="dashPlace1"></div></td><td style="width:33%;"><div id="dashPlace2"></div></td>
</tr><tr>
<td style="width:33%;"><div id="dashPlace3"></div></td><td style="width:33%;"><div id="dashPlace4"></div></td>
</tr>
</table>
So far so groovy.
The form handler then goes through to locate each dashPlace control to place the data inside it. The following code locates them and is msgboxing the control ID name as proof that it finds the controls....
Code:
Dim myCtl As Control
Dim tblRow As TableRow
Dim tblCell As TableCell
For Each tblRow In tbl.Rows
Dim ctl As Control
For Each tblCell In tblRow.Cells
For Each ctl In tblCell.Controls
If ctl.ID <> "" Then
If Left(ctl.ID, Len(ctl.ID) - 1) = "dashPlace" Then
MsgBox(ctl.ID)
'ctl.Controls.Add(myPart)
End If
End If
Next
Next
Next
I then get a series of MsgBoxes listing each name. Excellent! However, if I uncomment the ctl.Controls.Add(myPart) line, the HTML resulting HTML is...
Code:
<table id="PortletDataTable" border="0">
<tr>
<td style="width:33%;"><div id="dashPlace1"></div></td><td style="width:33%;"><div id="dashPlace2"></div></td>
</tr><tr>
<td style="width:33%;"><div id="dashPlace3"></div></td><td style="width:33%;"><div id="dashPlace4">
MyControl1Source
MyControl2Source
MyControl3Source
MyControl4Source
</div></td>
</tr>
</table>
....which just confuses me. The idea is that the dashPlace controls are used as a placemark for each control, yet it is only chucking them in the last DIV. I have also otried PlaceMark controls etc and get the same thing so its obviously something fundamental I'm getting wrong. What confuses me is that I would assume if the preceeding MsgBox command is returning the ID "dashPlace1", I would assume that I am working with a different control!
Any help, as always, most appreciated chaps!