我在更新面板中有占位符。在 Page_Load 我通过以下代码加载用户控件:
Control ctrl = LoadControl("~/UserControls/ListViewThumbs.ascx");
ucThumbs = (ListViewThumbs)ctrl;
ucThumbs.ID = "ucThumbs";
ucThumbs.SelectedIndexChanged += new UserControlSelectedIndexChanged(listView_SelectedIndexChanging);
ucThumbs.ItemDoubleClicked += new UserControlItemDoubleClicked(UserControlDoubleClicked);
ucPH.Controls.Clear();
ucPH.Controls.Add(ucThumbs);
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = ucThumbs.UniqueID;
trigger.EventName = "ItemDoubleClicked";
updateMyDocs.Triggers.Add(trigger);
下面的aspx代码:
<asp:UpdatePanel ID="updateMyDocs" UpdateMode="Always" ChildrenAsTriggers = "true" EnableViewState = "true" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="ucPH" runat="server"></asp:PlaceHolder>
</ContentTemplate>
单击用户控件会导致完全回发。我该如何预防?