Monday, March 26, 2012

Trouble firing events in code behind of user control

Ahoy

I am trying to use an asp:linkbutton on a .ascx file (user control), but it does not seem to be firing the click event in the code behind. I have put breakpoints on the first line of the event and in the page load of the user control, but it does not get to any of these. All it does is it postbacks to the server and goes through the page load event of the actual form (.aspx) that the user control is sitting on.

Any ideas?

ThanksAhoy

I am trying to use an asp:linkbutton on a .ascx file (user control), but it does not seem to be firing the click event in the code behind. I have put breakpoints on the first line of the event and in the page load of the user control, but it does not get to any of these. All it does is it postbacks to the server and goes through the page load event of the actual form (.aspx) that the user control is sitting on.

Any ideas?

Thanks

How are you assigning the Click Event to teh LinkButton and how are you handling it?
The following code is placed on the .ascx for the linkbutton's click event

Private Sub lnkLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkLogin.Click

'code

End sub

...it just never goes thru this code
Hmm that should not happen. Are you sure you are running on "Debug" mode and ASP.Net "Debugging" is enabled?
Make sure you are reloading your controls onto the form after the postback, or else the events for them wont fire. Happened to me :wave:
Yeh that was my problem - wasnt reloading the user controls on postback.

thanks patch :thumb:

0 comments:

Post a Comment