M
Matt MacDonald
Hi everyone,
I'm have a table in my aspx page that has 1 row which will contain 0 or
more cells. Each cell will contain a link button. My code is something
like this:
Dim lb As New System.Web.UI.WebControls.LinkButton
lb.Text = row("filename")
lb.CommandName = "GetAttachment"
lb.CommandArgument = row("attachmentID")
lb.Attributes("onclick") = "LinkButton_Command"
Dim cell As New System.Web.UI.WebControls.TableCell
cell.Controls.Add(lb)
cell.Visible = True
tblAttachments.Rows(0).Cells.Add(cell)
Where row is a row from a datatable in a dataset. Everything works fine
except that the "onclick" attribute doesn't work. If i manually code a link
button into my form, then it works fine. The problem "I think" is how the
control is being rendered. When I manually code the link button like:
"<asp:linkbutton text="button" Oncommand="LinkButton_Command"
CommandName="GetAttachment" CommandArgument="95" Runat=server/>" it renders
like this:
<a href="javascript:__doPostBack('_ctl0','')">button</a>. But when I make
it like in the above code, It renders like this:
<a onclick="LinkButton_Command" runat="server"
href="javascript:__doPostBack('_ctl1','')">FFIS2.vsd</a>, which is not
right. Anybody have any suggestions on this? Thanks alot,
Matt
PS, using oncommand instead of onclick does work either
I'm have a table in my aspx page that has 1 row which will contain 0 or
more cells. Each cell will contain a link button. My code is something
like this:
Dim lb As New System.Web.UI.WebControls.LinkButton
lb.Text = row("filename")
lb.CommandName = "GetAttachment"
lb.CommandArgument = row("attachmentID")
lb.Attributes("onclick") = "LinkButton_Command"
Dim cell As New System.Web.UI.WebControls.TableCell
cell.Controls.Add(lb)
cell.Visible = True
tblAttachments.Rows(0).Cells.Add(cell)
Where row is a row from a datatable in a dataset. Everything works fine
except that the "onclick" attribute doesn't work. If i manually code a link
button into my form, then it works fine. The problem "I think" is how the
control is being rendered. When I manually code the link button like:
"<asp:linkbutton text="button" Oncommand="LinkButton_Command"
CommandName="GetAttachment" CommandArgument="95" Runat=server/>" it renders
like this:
<a href="javascript:__doPostBack('_ctl0','')">button</a>. But when I make
it like in the above code, It renders like this:
<a onclick="LinkButton_Command" runat="server"
href="javascript:__doPostBack('_ctl1','')">FFIS2.vsd</a>, which is not
right. Anybody have any suggestions on this? Thanks alot,
Matt
PS, using oncommand instead of onclick does work either