Hello everyone,
I am creating a web control by addin the html in the code behind, like this:

Code:
 Dim sb As New StringBuilder
        Dim myDiv As HtmlGenericControl = Me.theContainer

 sb.Append("<table width='100&#37;'  cellpadding='0' cellspacing='0' style='border:0px;'>" & vbCrLf)
        sb.Append(" <tr class='mainRow1'>" & vbCrLf)
        sb.Append("<td  align='left'  style='border:0px solid white;'>Main Menu</td>" & vbCrLf)
        sb.Append("<td>" & vbCrLf)
        sb.Append("<asp:Label ID='Label1' runat='server' Text='Label'></asp:Label>" & vbCrLf)
        sb.Append("</td>" & vbCrLf)
        sb.Append("<td  align='right' style='border:0px solid white;'>Sort By: Id | Name</td>" & vbCrLf)
        sb.Append("</tr>" & vbCrLf)
        sb.Append("</table>" & vbCrLf)

 myDiv.InnerHtml = sb.ToString
This will generate the html for the table in the codebehind then inject it into the specified DIV element. My question is, if I create a control in this manner, how do i add an event that will fire a method in my codebehind? For example, if i want to create a image button i would do it this way in the code:
Code:
           <asp:ImageButton CommandArgument='<%# (Container.DataItem.objectValue) %>'            
ID='ImageButton1' runat='server' OnCommand='Button1_Click' ImageUrl='~/images/folder.gif' />
but in the code behind i would do this:
Code:
sb.Append("<input type='image' name='ctl00$ContentPlaceHolder1$importWizard1$folderControl1$folderRepeater$ctl04$ImageButton" & myCounter & "'")
sb.Append(" id='ctl00_ContentPlaceHolder1_importWizard1_folderControl1_folderRepeater_ctl04_ImageButton" & myCounter & "'")
sb.Append(" src='images/folder.gif' style='border-width:0px;'  />" & vbCrLf)
But I cant add the OnCommand because it wont be rendered properly.

Thanks for your help
jason