views:

277

answers:

3

I have a button which is in update panel. When I click on button then it click event run two times. How can I prevent second time click event?

A: 

Check if you did not attach the handler function twice to the click event (for example once by html/javascript and once in the vb code).

Ando
I didn't attach any html/javascript event only using update panel to run a process on handler of button.
Deepak
A: 

Why not disable the button at the start of the button callback function...

Then, using something sensible like a try/finally block, enable the button at the end, in the finally.

Rob L
oops. just saw it was an asp.net related thing. sorry. got my head stuck in desktop based code at the moment.
Rob L
A: 

On Page load, you can use:

button.Attributes.Add("onClick", "<< javascript >>")

... to attach some javascript to the Click event of the button.

You can find javascript to disable the button with a simple Google search.

Richard
I don't want to add any javascript with button. I am using update panel and a button in update panel but when I click on that button the handler of button runs twice. So my process runs twice. I wanna run that process single time.
Deepak
Well without seeing your code I'm not really sure what you're doing to get that kind of result, but it sounds like something is wrong with your implementation of UpdatePanel. My advice is to determine if the problem you're having is because of something server side (i.e. in your code) or your client side.
Richard