sineater213
New Member
Example : I have a table with two columns and three rows, and each cell i want to put an image button with different 'onclick funtion'. But it's not work, it said that : <BR><BR>"'ImageButton' must be placed inside a form tag with runat=server"<BR><BR>Can u help me to solve the problem?<BR><BR>TotRec = 6<BR>Dim Table(TotRec) as Table<BR>Dim ImgDel(JmlRec) as ImageButton<BR>Dim TableRow As TableRow<BR>Dim TableCell As TableCell<BR>For Cnt = 1 to TotRec<BR> ImgDel(Jml) = New ImageButton()<BR> ImgDel(Jml).ImageUrl = "../Images/Edit.gif"<BR> ImgDel(Jml).ID = Cnt<BR> Tabel(jml) = New Table()<BR> For i = 1 to 2<BR> TableRow = New TableRow()<BR> TableRow.HorizontalAlign = 2<BR> For j = 1 to 3<BR> TableCell = New Tablecell()<BR> TableCell.Controls.Add(ImgDel(Jml))---------> error in here<BR> tableRow.Cells.Add(tableCell)<BR> Next j<BR> tabel(jml).Rows.Add(tableRow)<BR> Next i<BR>Next Count<BR><BR>All you have to do is add your code to the page load. It should work fine because it will add your table to the form.Ok. You also need to do this:<BR><BR> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<BR> dim form as System.Web.UI.HtmlControls.HtmlForm = New System.Web.UI.HtmlControls.HtmlForm()<BR> table = New System.Web.UI.HtmlControls.HtmlTable()<BR> form = Me.FindControl("form1")<BR> form.Controls.Add(table)<BR> End Sub<BR><BR>