Click here to Skip to main content
Rate this: bad
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
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) {
     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
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)
Sunnykumar08 at 5-Nov-12 6:56am
sure, send it to me @
neeraj@max at 6-Nov-12 1:30am
i made a video of it...
kindly check it out
Rate this: bad
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

rearrange your both panel positions ...
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 Zoltán Zörgő 380
1 Sergey Alexandrovich Kryukov 185
2 OriginalGriff 150
3 Mika Wendelius 83
4 Peter Leow 80
0 Sergey Alexandrovich Kryukov 8,373
1 OriginalGriff 6,466
2 Peter Leow 3,567
3 Zoltán Zörgő 3,316
4 Richard MacCutchan 2,397

Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2015
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