Click here to Skip to main content
13,006,530 members (62,329 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 19: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 Coding:)

Sunny K
neeraj@max 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 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 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 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 5-Nov-12 6:56am
sure, send it to me @
neeraj@max 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 23 Nov 2012
Copyright © CodeProject, 1999-2017
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