creating button onclick events programmatically

  • Thread starter Thread starter barry
  • Start date Start date
B

barry

Is it possible to create the following programmatically

Button27.Attributes("onClick") = "javascript:abc();"

without creating a separate line for each

Button27.Attributes("onClick") = "javascript:abc();"
Button28.Attributes("onClick") = "javascript:abc();"
etc

thanks
barry
 
Barry,

You could write a loop that searches for each button and adds the
javascript.

Dim ButtonFound As Button
Dim ButtonCount, ButtonLoop As Int32
ButtonCount = 28

For ButtonLoop = 1 To 28
ButtonFound = Page.FindControl("Button" & ButtonLoop.ToString)
ButtonFound.Attributes.Add("onClick", "javascript:abc();")
Next

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
Thank you very much.
S. Justin Gengo said:
Barry,

You could write a loop that searches for each button and adds the
javascript.

Dim ButtonFound As Button
Dim ButtonCount, ButtonLoop As Int32
ButtonCount = 28

For ButtonLoop = 1 To 28
ButtonFound = Page.FindControl("Button" & ButtonLoop.ToString)
ButtonFound.Attributes.Add("onClick", "javascript:abc();")
Next

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top