2

我在更新面板中有占位符。在 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>

单击用户控件会导致完全回发。我该如何预防?

4

1 回答 1

0

我会将更新面板放在 userControl 内部而不是外部。

当您将 UserControls 放入其中时,更新面板会出现这样的问题

于 2012-07-18T14:40:27.240 回答