473,386 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

creating button onclick events programmatically

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
Nov 19 '05 #1
2 1924
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
"barry" <fl******@ix.netcom.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2
Thank you very much.
"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:uR**************@TK2MSFTNGP12.phx.gbl...
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
"barry" <fl******@ix.netcom.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
7
by: Dragon | last post by:
Hi, I am trying to create a form and add some controls to it programmatically. I am pasting the code I have so far, below. here are the issues I am having. #1. I am having to subtract...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
11
by: cindy | last post by:
I have a form, has javascript registered so a modal pops up. Button click will close form. Now I need to do an update with modal form data before it closes. I can put a second button and register...
4
by: Bob | last post by:
Hi, I'm working with VWD and i defined programmatically a button (in code-behind) with an ID. So I expect to see beside "Page Events" and "Form1" my button "b1" in order to use the Click event....
1
by: Mateo | last post by:
Hi! Let's say You generate button from code. Web forms control, not HTML button. How can I catch it's OnClick event? Where to put code which is exedcuted on buttons OnClick event? Thanx! ...
0
by: Tom | last post by:
The included code block demonstrates programmatically clicking a non-derived ToolStripButton in the OnShown() method. When I derive a button from ToolStripButton and override the _private_...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.