Update parent updatepanel from within usercontrol


I have an update panel that contains a repeater that calls a user control into each row. When I click a button inside the user control, the page does not refresh at all, only when I reload it completely. How can I make the update panel refresh from user control's button click?

Best Solution

Phairoh is correct that your button needs to successfully cause a PostBack.

There are three things that affect when a UpdatePanel is updated:

  1. The UpdateMode property - This takes two possible values, Always and Conditional.
    • If it is set to Always then any postback o the page will cause the UpdatePanel to update.
    • If it is set to Conditional then the UpdatePanel is only updated when the UpdatePanel's Update method is called or when one of the UpdatePanel's triggers does a postback.
  2. The Triggers proroperty - Defines which controls will cause the UpdatePanel to be updated when UpdateMode is set to Conditional.
  3. The ChildrenAsTriggers property - This is a boolean value that determines if child controls of the UpdatePanel are automatically considered triggers without having to be added to the Triggers collection.

Because your button is in a UserControl it won't be easy to add the control to the Triggers collection or to have the button call the Update method on the UpdatePanel that is not inside the UserControl.

Because your UpdatePanel contains the UserControl's your best bet is to enable ChildrenAsTriggers. If this doesn't work try setting the UpdateMode property to Always. If this still doesn't work then Phairoh is probably correct and your Button isn't posting back.

Related Question