RaisePostBackEvent does not fire

I have a custom control that implements IPostBackEventHandler. Some client-side events trigger __doPostBack (controlID, eventArgs).

The control is implemented in two different user controls. In a single control, RaisePostBackEvent runs on the server side when called __doPostBack. In another control, RaisePostBackEvent is never called. I checked the parameter __EVENTTARGETand it matches the ClientID of the control ... where else can I try to fix this problem?

+5
source share
2 answers

There can be many ways to fall apart. Are you adding a control to the page dynamically in code? If so many times your UniqueID can be turned off - even if the client ID is equal. Do you have sample code that can demonstrate what you are doing?

+1
source

Double-check that this is really the output of the UserControl class, not WebControl.
This one took me by surprise many times. If you need to use WebControl for styling, you need to let your management implement INamingContainer. (Don’t worry, its marker interface)

So..

public class MyControl : UserControl {}

or

public class MyControl : WebControl, INamingContainer {}
0
source

All Articles