Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 C#
i have two panel in ma form. panel1 with button1 on it at location let say x:10,y:10 and panel2 with button 2 on it at location x:10,y:10.
 
what actually button1 do:- it hide panel1 and shows panel2 at the same location.
 
but whenever i click on button1 twice after completion its process it fire button2 click event,
 
plz help me ASAP
Posted 4-Nov-12 20:47pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi Neeraj,
 
The reason behind this cause is called "<b>Event Bubbling</b>" in JavaScript. It means the Browser catches the event for every underlying element on a particular point. in order to override this behavior, add these code lines after you code in JS function which is being called on button1 click but just before the closing parenthesis of the function:
function stopEvent(evnt) {
    if (evnt.stopPropagation) {
             evnt.stopPropagation();
     }
     else {
        evnt.cancelBubble = true;
     }
   }
 
the code above will prevent the event bubbling after the code inside your js function is executed.
 
Hope this helps!
Happy CodingSmile | :)
 
Sunny K
  Permalink  
Comments
neeraj@max at 5-Nov-12 3:04am
   
hello sunny... thanks for your quick response....
 
i work on window mobile app and we cant use js queries in it.
 
if you have anythng for window plz let me know.
 
thanks once again.
Sunnykumar08 at 5-Nov-12 3:41am
   
would be great if u share the code what you've tried yet, so that we can get a better picture of the situation. thanks.
neeraj@max at 5-Nov-12 5:39am
   
i was trying to put snapshots but unable to make it here... can i have your mail id so, i can send it to you...
 
it would be more clear by images instaed of code actually.
neeraj@max at 5-Nov-12 5:58am
   
private void Form1_Load(object sender, EventArgs e)
{
panel1.Visible = false;
panel2.Visible = false;
panel1.Visible = true;
panel1.Location = new Point(0, 0);
}
private void button1_Click(object sender, EventArgs e)
{

panel1.Visible = false;
panel2.Location = new Point(0, 0);
panel2.Visible = true;

}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("2");
 
}
Sunnykumar08 at 5-Nov-12 6:56am
   
sure, send it to me @ ebayermailid@gmail.com
neeraj@max at 6-Nov-12 1:30am
   
http://www.youtube.com/watch?v=bpojl4XMweo&feature=g-upl
 
i made a video of it...
kindly check it out
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

by ignoring queued mouse events. i got my answer.
 
@everybody: thank you every one for your suggestions.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

rearrange your both panel positions ...
  Permalink  
Comments
neeraj@max at 21-Nov-12 1:51am
   
i alredy did that but it is not workng...

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

  Print Answers RSS
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100