I would like an UpdatPanel to update it's content once a button is clicked - this button is contained within a UserControl placed on the webpage.
However, I cannot just simply reference it using the AsyncPostBackTrigger's ControlID property, 开发者_开发技巧because the button is not situated directly on the webpage.
Is there any way to reference it to the AsyncPostBackTrigger?
Use RegisterAsyncPostbackControl, e.g. if you have a user control UserControl1
containing Button1
and your script manager is called ScriptManager1
:
ScriptManager1.RegisterAsyncPostbackControl(UserControl1.FindControl("Button1"));
Edit:
This will refresh all update panels, except panels that have their property set to conditional. For these panels you need to call UpdatePanel.Update();
in the code for the button.
Does the user control expose the button as a child control? If not can it? If not then you can use FindControl
on the user control to find the inner button.
精彩评论