0

我有两个嵌套的更新面板,我从源代码更新面板,但没有任何效果。代码如下

<div style="display:block; clear: left;" runat="server" id="DivLike">
    <asp:UpdatePanel ID="UpdatePanelLike" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div style="position: relative;">
                <div style="position: absolute; top: 0px; left: 0px;">
                    <asp:LinkButton ID="LinkButtonLike" runat="server" CommandName='<%#Eval("Like_Command") %>'
                    Font-Size="XX-Small" OnCommand="LinkButton2_Command" Text='<%#Eval("Like_Command")%>'></asp:LinkButton>
                </div>
                <div class="popupstyle" style="position:absolute; top:0px; left:0px; display:none;"
                id="DivChapters" runat="server">
                    <asp:UpdatePanel ID="UpdatePanelLinkActivity" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <div>Select Chapter:
                                <asp:DropDownList ID="DropDownListChapters" runat="server"
                                AutoPostBack="true" OnSelectedIndexChanged="DropDownListChapters_SelectedIndexChanged"></asp:DropDownList>
                            </div>
                            <div>Select Topic:
                                <asp:DropDownList ID="DropDownListTopics" runat="server"></asp:DropDownList>
                            </div>
                            <div>
                                <asp:LinkButton ID="LinkButtonAddLink" runat="server" OnCommand="LinkButtonAddLink_Command"
                                Text="Add" CssClass="UtilityClass"></asp:LinkButton>
                            </div>
                            <asp:UpdateProgress ID="UpdateProgressLinkActivity" runat="server" AssociatedUpdatePanelID="UpdatePanelLinkActivity"
                            DynamicLayout="True">
                                <ProgressTemplate>
                                    <div style=" position:absolute; top:50%; left:50%; background-color:white;"
                                    id="divLoading">
                                        <img src="Images/loading25.gif" alt="Loading..." style="" />
                                    </div>
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="LinkButtonAddLink" EventName="Command"
                            />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="LinkButtonLike" EventName="Command"
            />
        </Triggers>
    </asp:UpdatePanel>
</div>

下面的代码后面更新了面板,但没有更新任何面板。虽然当我用调试器分析它时,每一件事都被完美地分配了。

 protected void DropDownListChapters_SelectedIndexChanged(object sender, EventArgs e )
 {
    DropDownList DDL = (DropDownList)sender;
    DropDownListTopics.DataSource = ChapterDataAccess.GetUserTopics(Convert.ToInt32(DDL.SelectedItem.Value), new Guid(Membership.GetUser().ProviderUserKey.ToString()));
    DropDownListTopics.DataTextField = "Name";
    DropDownListTopics.DataValueField = "Id";
    DropDownListTopics.DataBind();
    ListItem item=new ListItem ("topics","value" );
    DropDownListTopics.Items.Add(item);
    UpdatePanel thepanel= (UpdatePanel)DDL.Parent.Parent;
    UpdatePanel theparentpanel=(UpdatePanel)DDL.Parent.Parent.Parent.Parent.Parent ;
    theparentpanel.Update();
    thepanel.Update();


}
4

1 回答 1

0

我认为您没有正确访问更新面板..

当 UpdatePanels 没有包含在另一个 Content Placeholders 中时,我认为您可以直接访问 Update Panels 而不是使用父级来查找它。

简单地

UpdatePanelLinkActivity.Update();
UpdatePanelLike.Update() ;   

应该做..

于 2012-10-01T04:00:30.663 回答