[Resolved] 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?
Thanks
Re: Trouble firing events in code behind of user control
Quote:
Originally Posted by muri
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?
Thanks
How are you assigning the Click Event to teh LinkButton and how are you handling it?
Re: Trouble firing events in code behind of user control
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
Re: Trouble firing events in code behind of user control
Hmm that should not happen. Are you sure you are running on "Debug" mode and ASP.Net "Debugging" is enabled?
Re: Trouble firing events in code behind of user control
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:
Re: [Resolved] Trouble firing events in code behind of user control
Yeh that was my problem - wasnt reloading the user controls on postback.
thanks patch :thumb: