I have an Repeater control sitting on my page, in the ItemTemplate of which are a couple of Button controls which do various things – delete the item, open the item’s detail pages etc… I think it would be nice to wrap the whole thing in an UpdatePanel to give it that whole AJAX-y feel. All good.
Then the client asks if the buttons can be links instead of buttons. No problem, think I, and go ahead and change the Buttons to LinkButtons. At which point the application stops working. Clicking on the link buttons does a full post back (even though they’re in the UpdatePanel) and their associated methods in the code do not fire. Very strange. I remove the UpdatePanel and the methods fire. All very odd.
Now, I don’t like giving IDs to controls that I don’t reference directly in the code. So as a matter of course I remove IDs from things like Buttons, LinkButtons etc… Which is all fine until you put a LinkButton in an UpdatePanel – where an ID is necessary.
So, if you have a LinkButton within an UpdatePanel and it is doing an unexpected post back and the onclick event is not firing, check that you have an ID on it.
Hi, thank you for your post
I’m looking over 3 hours to figure out why doesn’t LinkButton’s Click event fire when I have it dynamically added into an updatepanel, sounds nothing. even your solution didn’t work, my controls already have IDs associated with.
Have you any other idea how to solve this problem?
Hi Farzan,
This sounds like a problem to do with the LinkButton not being part of the page control tree at the time when its Post Back Event would be called.
Does it happen outside of the UpdatePanel too?
How exactly are you adding the linkbutton to the page?