473,756 Members | 7,560 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to "program" a button's click ?

Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would like
that the second one will be click too (by programming) ... something like
button2.click ???

Thanks for help ..
Apr 26 '07 #1
6 2808
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would
like
that the second one will be click too (by programming) ... something
like
button2.click ???
Thanks for help ..
Do you mean that both serverside handlers should be executed?
The Button2_Click handler is just a method, so nothing prevents you
from calling that from Button1_Click. Although is might be better to
have the code that you want executed for both buttons in a separate
method, that you call from both handlers.

Hans Kesting
Apr 26 '07 #2
You don't need to actually "click" the second button.
In fact, I'd bet you don't even need a second button.
If you run the second button's click event, the page will be submitted twice,
once with the first button and the second time with the second button.

That second button probably calls a function, right ?
Just call the function with your first button and get rid of the second button.

If you still want to click a second button, you can use Javascript :

var clickbutt = document.getEle mentById(Second ButtonName);
if (clickbutt)
{
clickbutt.click ();
}

I don't know why you'd want to do that, though.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"user" <us**@user.comw rote in message news:On******** ******@TK2MSFTN GP04.phx.gbl...
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would like that the second one
will be click too (by programming) ... something like button2.click ???
Thanks for help ..

Apr 26 '07 #3
On Apr 26, 12:59 pm, "user" <u...@user.comw rote:
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would like
that the second one will be click too (by programming) ... something like
button2.click ???

Thanks for help ..
There is no real way to have both buttons pushed however you can
program it so that when button 1 is pressed they get the same results
that happen with button 2.

Presuming you are in visual studio or the web express version and want
to do the code on the server end you do the following, if you want to
do this all on the client end you will need to do it using ecmascript
aka javascript and that would be better asked in another group;
however the general idea would be the same.

As for on the server side go into the design view and drag a button to
the screen and double click on the first button, this will generate
the code framework needed to handle the button.

Now you will need to write the code you want to execute, do what you
want for each button in a separate function then in the area for
button 1 call both of those functions. Then go back and drag button 2
where you want it and double click and call the function for button 2
in that place. If you want both buttons to do the same thing then
just write one function and have both button events call it.
Apr 26 '07 #4
In the Button1_Click handler you can call:
Button2_Click(n ull,null);

Seems like kind of a dorky way to do things though. See the other posters'
recommendations .
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"user" wrote:
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would like
that the second one will be click too (by programming) ... something like
button2.click ???

Thanks for help ..
Apr 26 '07 #5
On 26 Apr, 17:26, Peter Bromberg [C# MVP]
<pbromb...@yaho o.yabbadabbadoo .comwrote:
In the Button1_Click handler you can call:
Button2_Click(n ull,null);

Seems like kind of a dorky way to do things though. See the other posters'
recommendations .
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"user" wrote:
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would like
that the second one will be click too (by programming) ... something like
button2.click ???
Thanks for help ..- Hide quoted text -

- Show quoted text -
I strongly recommend that you create a separate sub-routine (or
procedure depending on source language) to execute the code contained
in the button2 click event handler and call that from both handlers.
Futhermore give at a descriptive name that helps to document its
purpose.

I know this suggestion is not original but it's the cleanest way to
implement re-usable code.

HTH

Apr 26 '07 #6
Thanks ! i want to do it first to avoid a duplicate insert action with F5
button by click on a select bouton after click the insert button ...
Finally i used response.redire ct(selfpage) to avoid the duplicate data..

Thanks again !

"user" <us**@user.co ma écrit dans le message de
news:On******** ******@TK2MSFTN GP04.phx.gbl...
Hello,
With ASP.NET2, how to program a button's click ?
For example, I have two button and when i click the first one, i would
like that the second one will be click too (by programming) ... something
like button2.click ???

Thanks for help ..

Apr 27 '07 #7

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

Similar topics

11
2337
by: tdi | last post by:
Ok, stupid question for the day. I'm reading the interview with Steve Moret and he says: "Once a lot of scripts started going in we knew there was no way we could back out of using Python." I'm just getting into Python and am wondering if I'm missing something or this is just a semantic issue. Thanks. -Ted
1
1858
by: Dgates | last post by:
This request might belong in a "SQL"-related newsgroup, but it's such a pain using Agent to subscribe to a new group (and download its 50,000 messages!) just to ask one question. So, since it deals with an ASP.NET app, I thought I'd ask here. ============================================== I am using Web Data Adminstrator, which I downloaded recently from the Microsoft site. I get an error when I create tables or columns:
14
2409
by: RDI | last post by:
I'm in the process of wiritng a custom AutoResponder that will run on a spare PC. If I don't write it as an actual "Service" but just a program that starts via the startup folder, will that use any more (or less) resources than doing it as a Service? Is it worth the extra effort to do it as a service? --
2
2781
by: monkey3333sg | last post by:
I would like to add an "undo" button in my programme
2
4052
by: sdanda | last post by:
Hi, I am working on C#. We have a tool called WHOST.exe which is a VC++ MFC application. Recently I modified the application and regenerated the WHOST.exe in Visual Studio 2008. If i open the WHOST.exe in my system it is working but if i open the WHOST.exe in my friend's system its not opening through commnad prompt or by double clicking the WHOST.exe. If i open the WHOST.exe through command prompt it is saying that " The system cannot execute...
9
2917
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading the text files from the watched folder line by line into variables and then posting them to a SQL table. All of the code for the form is shown below. And it works fine except for 2 issues. First issue: In the Finally of the Try for teh SQL...
10
1775
by: pstve | last post by:
Hi, I've got a problem! Or two actually at this moment... I want to: - When I'm installing my program (coded in C#, installed on computer by windows installer), we can call it for "Program A", I want another program (a .exe file), "Program B", to install simultaneously without users knowledge. If I put "Registers" value to "csdrfCOMSelfReg" for the .exe file in "Properties" I will get the possibility to click through an installer...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.