Click here to Skip to main content
16,018,318 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi dears.
I have three button in my form and i want if user click button1,button2 & button3 be clicked.
Posted
Comments
bbirajdar 14-Aug-12 5:01am    
You can add a note below the first button - " Dear user, if you click button1, then please click button2 and button3 also".

How can we guess what you want to achieve without seeing your code and with this less information you provided ?
siasalar 14-Aug-12 6:34am    
I understand a little english therefore i coud not explain more to what i want to achieve. anyway i got the soloution.
Thanks alot.
pradiprenushe 14-Aug-12 5:04am    
why you require this behaviour?
AshishChaudha 14-Aug-12 5:04am    
I am not sure, what I understand is that you want a click event of Button2 and Button3 on Click Event of Button1.am I right??
AmitGajjar 14-Aug-12 5:57am    
rather then click the button2 and button3 , you should create two function for button2 and button3 handler and then call that function on button1 click event.

if you are using windows application then,
C#
protected void Button1_Click(object sender, EventArgs e)
   {
       button2.performClick();
       button3.performClick();
   }


if you are using web application then
C#
protected void Button1_Click(object sender, EventArgs e)
   {
       Button2_Click(Button2, e);
       Button3_Click(Button3, e);
   }

Happy Coding!
:)
 
Share this answer
 
Comments
siasalar 14-Aug-12 5:23am    
Happy coding :D
Thanks dude.
Aarti Meswania 14-Aug-12 5:26am    
welcome :)
Try this

C#
string test = "";
  
   protected void Button1_Click(object sender, EventArgs e)
   {
       Button2_Click(sender, e);
       Button3_Click(sender, e);
   }
   protected void Button2_Click(object sender, EventArgs e)
   {
       test = "Button2";
   }
   protected void Button3_Click(object sender, EventArgs e)
   {
      lblmsg.Text= test + "and Button3 clicked";
   }
 
Share this answer
 
v3
Comments
AshishChaudha 14-Aug-12 5:05am    
my +5
Sachin Gargava 14-Aug-12 5:11am    
thanks ashish
siasalar 14-Aug-12 5:27am    
Thank's dude.
Try this Code:-

C#
protected void Button1_Click(object sender, EventArgs e)
{
    this.Button2.Click +=new EventHandler(Button2_Click);
    this.Button3.Click +=new EventHandler(Button3_Click);
    MessageBox.Show("Buton 2 and Button3 are clicked", "Button1",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
protected void Button2_Click(object sender, EventArgs e)
{
    //Some Code Here
}   
protected void Button3_Click(object sender, EventArgs e)
{
   //Some Code Here
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900