R
roblaro
Hello,
I have an asp.net 2.0 app that will create a group of linkbuttons at
runtime. The ID of these links buttons will autogenerated.
I want to write a method that will be fired when any one of these buttons is
clicked. For some reason I can not figure out how to do this.
Here is some code:
Private Sub Create_Buttons()
...some code is run here to execute a stored proc and fill a datareader...
While rd.Read()
btn = New LinkButton
btn.Text = rd("CONSIGNEE_INFO").ToString() & "<br><br>"
btn.ID = rd("ADDR_ID").ToString()
btn.ForeColor = System.Drawing.Color.FromArgb(100, 51,
51, 51)
btn.Attributes.Add("style", "text-decoration: none;")
btn.Attributes.Add("onMouseOver",
"this.style.backgroundColor='#93c0ee';")
btn.Attributes.Add("onMouseOut",
"this.style.backgroundColor='#ecf0f4';")
btn.CommandName = "MyCommand"
btn.CommandArgument = rd("ADDR_ID").ToString()
...popAddr is a <div></div> layer that is set to runat="server" and
will
hold all of the runtime buttons...
popAddr.Controls.Add(btn)
End While
rd.Close()
End Sub
I thought that I would simply be able to use btn.OnCommand to pass the
method I want to execute, however, it says that its protected.
How can I get this to work?
Thanks!
I have an asp.net 2.0 app that will create a group of linkbuttons at
runtime. The ID of these links buttons will autogenerated.
I want to write a method that will be fired when any one of these buttons is
clicked. For some reason I can not figure out how to do this.
Here is some code:
Private Sub Create_Buttons()
...some code is run here to execute a stored proc and fill a datareader...
While rd.Read()
btn = New LinkButton
btn.Text = rd("CONSIGNEE_INFO").ToString() & "<br><br>"
btn.ID = rd("ADDR_ID").ToString()
btn.ForeColor = System.Drawing.Color.FromArgb(100, 51,
51, 51)
btn.Attributes.Add("style", "text-decoration: none;")
btn.Attributes.Add("onMouseOver",
"this.style.backgroundColor='#93c0ee';")
btn.Attributes.Add("onMouseOut",
"this.style.backgroundColor='#ecf0f4';")
btn.CommandName = "MyCommand"
btn.CommandArgument = rd("ADDR_ID").ToString()
...popAddr is a <div></div> layer that is set to runat="server" and
will
hold all of the runtime buttons...
popAddr.Controls.Add(btn)
End While
rd.Close()
End Sub
I thought that I would simply be able to use btn.OnCommand to pass the
method I want to execute, however, it says that its protected.
How can I get this to work?
Thanks!