You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I create a composite control, that is basically just a wrapper around button and I use that control with defined PostBack handler, that handler does not get executed when invoking button click command.
The Bootstrap button, that is also defined as composite control, is affected by the same issue. This can be easily reproduced by creating dot:Button with command binded to click and defined postback handler - this works as expected, postback handler is executed before command, but when changed to bs:Button, postback handler is not executed.
Found workaround:
In the OnPreRender method we can select the dot:Button from Children collection (possibly nested in other controls, depending on your control tree) and the call button.SetValue(PostBack.HandlersProperty, this.GetValue<PostBackHandlerCollection>(PostBack.HandlersProperty)). However, this is a bit tiresome and not intuitive for the developer.
Also it would be great if this behavior and overall design of custom controls (classic as well as composite) were better described with more examples in docs. 🙏
PostBack.Handlers are copied onto the created controls, if they
contain a matching command binding.
* We map postback handlers onto the command bindings set on
the CompositeControl by comparing the EventName and property name
* For each control returned from GetContents, we enumerate its
command bindings and compare them to the command
bindings found on the CompositeControl.
* If a matching command binding is found, we clone its postback
handlers onto the child control. EventName is adjusted to
match the new property name
The control enumeration is done recursively before adding the
control to Children, thus walking only through the tree created in
this CompositeControl - nested CompositeControls,
initialized Repeaters, ... are not included.
In order to support templatws created in the CompositeControl,
we recurse into CloneTemplates. For DelegateTemplate or any
other more advanced needs, a protected
CopyPostBackHandlersRecursive method is provided.
resolves#1699
When I create a composite control, that is basically just a wrapper around button and I use that control with defined PostBack handler, that handler does not get executed when invoking button click command.
The Bootstrap button, that is also defined as composite control, is affected by the same issue. This can be easily reproduced by creating dot:Button with command binded to click and defined postback handler - this works as expected, postback handler is executed before command, but when changed to bs:Button, postback handler is not executed.
Found workaround:
In the OnPreRender method we can select the dot:Button from Children collection (possibly nested in other controls, depending on your control tree) and the call
button.SetValue(PostBack.HandlersProperty, this.GetValue<PostBackHandlerCollection>(PostBack.HandlersProperty))
. However, this is a bit tiresome and not intuitive for the developer.Also it would be great if this behavior and overall design of custom controls (classic as well as composite) were better described with more examples in docs. 🙏
@exyi
The text was updated successfully, but these errors were encountered: