Hi all
Here is my scenario:
1. I create a dynamic table.
2. Inside that table, I create dynamic panel
3. Inside the panel, there is a dynamic checkbox.
I want to add attributes for that checkbox.
Below is my code:
For Each drCab As DataRow In dt.Rows
Dim TempPanelrack As New Panel
Dim BtnCab As New Button
Dim chkcab As New CheckBox
TempPanelrack.HorizontalAlign = HorizontalAlign.Center
TempPanelrack.BorderStyle = BorderStyle.Inset
TempPanelrack.Width = 110
TempPanelrack.Height = 80
TempPanelrack.ID = drCab("REFNO_T")
BtnCab.Text = drCab("REFNO_T") & vbCrLf & "(" & CStr(drCab("NAME_T")).Substring(0, 12) & ")" & vbCrLf & "-" & CDate(drCab("FRDATETIME_D")).ToString("HH:mm") & "-"
BtnCab.BorderStyle = BorderStyle.Groove
BtnCab.ToolTip = drCab("NAME_T") & vbCrLf & "From: " & CDate(drCab("FRDATETIME_D")).ToString("dd/MM/yyyy HH:mm:ss") & vbCrLf & " To: " & CDate(drCab("TODATETIME_D")).ToString("dd/MM/yyyy HH:mm:ss") & " "
BtnCab.Attributes.Add("onclick", "Showdetails('" & drCab("REGISNO_T") & "');")
BtnCab.Width = 110
BtnCab.Height = 80
BtnCab.Font.Size = 8
BtnCab.Font.Bold = True
chkcab.ToolTip = drCab.Item("REFNO_T")
chkcab.BorderStyle = BorderStyle.None
chkcab.ID = drCab.Item("REFNO_T")
chkcab.Attributes.Add("onClick", "chkcabchecked('" & TempPanelrack.ID & "');")
TempPanelrack.Controls.Add(BtnCab)
TempPanelrack.Controls.Add(chkcab)
Dim TC As New TableCell()
TC.Controls.Add(TempPanelrack)
TR.Cells.Add(TC)
If CountCab Mod 4 = 0 Then
Me.tableALL.Rows.Add(TR)
TR = New TableRow()
Else
Me.tableALL.Rows.Add(TR)
End If
Private Sub chkcabchecked(ByVal panelid As String)
Dim mainContent As ContentPlaceHolder = DirectCast(Me.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
Dim tr As Table = DirectCast(mainContent.FindControl("tableALL"), Table)
Dim trpanels As Panel = DirectCast(tr.FindControl(panelid), Panel)
Dim chkbox As CheckBox = DirectCast(trpanels.FindControl("chkcab"), CheckBox)
If (Not chkbox Is Nothing) Then
MsgBox("Parent of the text box is : " & chkbox.ID)
Else
MsgBox("Control not found.....")
End If
End Sub
However, the error
that I get when I click on the checkbox is:
Microsoft JScript runtime error: 'chkcabchecked' is undefined