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?
Are you sure your buttons on your user control are attempting to do a postback? I haven't used update panels in a while (and I'd actually recommend avoiding them) but if I recall correctly they will refresh whenever a postback is done within them. This means that your buttons must be Asp:Buttons (or similar controls that cause postback) and not have some kind of javascript on them that would not allow their action to continue (such as a return false).
Phairoh is correct that your button needs to successfully cause a PostBack.
There are three things that affect when a UpdatePanel is updated:
- The
UpdateMode
property - This takes two possible values,Always
andConditional
.- 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'sUpdate
method is called or when one of the UpdatePanel's triggers does a postback.
- If it is set to
- The
Triggers
proroperty - Defines which controls will cause the UpdatePanel to be updated whenUpdateMode
is set toConditional
. - 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 theTriggers
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.