我正在设置UpdatePanel1.UpdateMode = UpdatePanelUpdateMode.Conditional;
进行手动更新,但它不适用于某些自定义事件,当我在这里有一些类似的事件时:
protected void Button1_Click(object sender, EventArgs e) {
discovery.FindAlreadyRegisteredServices();
discovery.discoveryClient.FindCompleted += FoundEvent;
protected void FoundEvent(object sender, FindCompletedEventArgs e) {
Label1.Text = (discovery.endpoints.Count > 0) ? discovery.endpoints[0].Address.ToString() : "nothing";
UpdatePanel1.Update();
}
我的项目失败了:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.Internals.dll
Additional information: The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' before Render.
即使我设置ChildrenAsTriggers
与否。错误消息对我来说不清楚,我不明白在处理我的事件后我应该怎么做才能处理更新?
添加:
aspx:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:ListView ID="ListView1" runat="server">
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>