LinkButtons needs to be clicked twice to fire the event

A

Author #1

LinkButtons needs to be clicked twice to fire the event

I have been bothered by this problem for a long time, but haven't
really found a solution. I also could not google out articles about
this. I doubt I am the only one who's had this kind of problem. This
problem seems to happen only if I ajax my controls.

The problem:

In my AJAXed asp.net 3.5 web application, I have a web form which
loads a few user controls dynamically. These user controls have some
LinkButtons. I notice that I sometimes I have to click on such link
buttons twice to fire the click event. I say sometimes, because I am
not sure about the pattern yet, but it seems that this happens after I
edit or delete something and rebind/reload my controls.

Because these user controls are dynamically added and their event
handlers are also wired dynamically in code-behind like this:

myUserControl.MyLinkButtonGetsClicked += new EventHandler
(myUserControl_MyLinkButtonGetsClicked );

I am suspecting that somehow, maybe due to ajax, the first click
causes a postback, during which the event handler gets wired up, but
the the event handler, i.e., myUserControl_MyLinkButtonGetsClicked,
does not get executed. The event handler gets executed the 2nd time
the Link Button is clicked.

Does this guess sound reasonable? If yes, how to shoot this problem?
Any article out there? Thanks.

I am aware that this may not be clear since I don't have code snippet
here. But just in case that you guys have had such problems.

If there is a need, I will follow up with the code snippets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top