簡體   English   中英

是否可以使用 updateprogress 刷新整個頁面?

[英]Is it possible to refresh the whole page using an updateprogress?

我正在嘗試在鏈接到 UpdatePanel (AsyncPostBackTrigger) 的頁面中實現重新初始化按鈕。 當我單擊該按鈕時,它會處理 UpdateProgress。

問題在於,因為重新初始化按鈕與更新面板鏈接,所以它無法重新初始化 UpdatePanel 之外的內容。

有沒有辦法在不為整個頁面添加 UpdatePanel 的情況下對 UpdatePanel 外部的控件進行一些更改? 在這種情況下,我想重新初始化 UpdatePanel 中包含的 DropDownLists、Textbox 和 Repeater。

頁面是如何呈現的

ASPX代碼:

<body style="padding: 50px;">
    <form id="form1" runat="server">
        <asp:Label runat="server" ID="test"></asp:Label>
        <asp:HiddenField runat="server" ID="AllDemandsTypeHfi"></asp:HiddenField>
        <asp:ScriptManager runat="server" ID="ScriptManager"></asp:ScriptManager>
        <asp:Panel runat="server" CssClass="panel-page-title">Création de demande</asp:Panel>
        <asp:Panel runat="server" CssClass="panel-primary">
            <asp:Panel runat="server" CssClass="panel-heading">Configuration de la recherche</asp:Panel>
            <asp:Panel runat="server" CssClass="panel-body">
                <asp:Table runat="server">
                    <asp:TableRow ID="BankRow">
                        <asp:TableCell>
                                <asp:Label runat="server">Banque : </asp:Label>
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:DropDownList runat="server" ID="BankDdl" AutoPostBack="true" OnSelectedIndexChanged="BankDdl_SelectedIndexChanged"></asp:DropDownList>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell>
                                <asp:Label runat="server">Famille : </asp:Label>
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:DropDownList runat="server" ID="FamilyDdl" AutoPostBack="true" OnSelectedIndexChanged="FamilyDdl_SelectedIndexChanged"></asp:DropDownList>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell>
                                <asp:Label runat="server">Motif : </asp:Label>
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:DropDownList runat="server" ID="MotiveDdl" AutoPostBack="true" OnSelectedIndexChanged="MotiveDdl_SelectedIndexChanged"></asp:DropDownList>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell>
                                <asp:Label runat="server">Sous-motif : </asp:Label>
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:DropDownList runat="server" ID="SubmotiveDdl" AutoPostBack="true" OnSelectedIndexChanged="SubmotiveDdl_SelectedIndexChanged"></asp:DropDownList>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell>
                                <asp:Label runat="server">Mots-clés : </asp:Label>
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="KeywordsTbx" data-target="#modalSuggestions" data-toggle="modal"></asp:TextBox>
                            <div id="keywordsTbxSuggestions"></div>
                            <asp:HiddenField runat="server" ID="KeywordsSearchHfi"></asp:HiddenField>
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
                <br />
                <asp:Button runat="server" ID="ResearchBtn" Text="Rechercher" OnClick="ResearchBtn_Click" />
                <asp:Button runat="server" ID="ReinitializeBtn" Text="Réinitialiser" OnClick="ReinitializeBtn_Click" />
            </asp:Panel>
        </asp:Panel>
        <br />
        <asp:UpdatePanel runat="server" ID="ResultsUpnl" ChildrenAsTriggers="true" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Panel runat="server" CssClass="panel-primary">
                    <asp:Panel runat="server" CssClass="panel-heading">Résultat de la recherche </asp:Panel>
                    <asp:Panel runat="server" CssClass="panel-body">
                        <asp:Label runat="server" ID="ResultsLb" Text="Veuillez sélectionner les critères de recherche, puis cliquer sur Rechercher."></asp:Label>
                        <asp:Repeater runat="server" ID="ResultsRpt">
                            <HeaderTemplate>
                                <asp:Label runat="server" Text="<b>Type de demande</b>"></asp:Label>
                                <table>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <asp:Panel runat="server">
                                    <asp:HyperLink runat="server" NavigateUrl='<%# Eval("Link") %>' Text='<%# Eval("Title") %>' Target="_blank"></asp:HyperLink>
                                </asp:Panel>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>
                    </asp:Panel>
                </asp:Panel>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ResearchBtn" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="ReinitializeBtn" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UppDemandsResult" runat="server" DisplayAfter="0">
            <ProgressTemplate>
                <div style="text-align: center;">
                    <table style="width: 100%;">
                        <tr>
                            <td>
                                <Loader:LoaderComponent ID="UcLoadingProgess" runat="server" />
                            </td>
                        </tr>
                    </table>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </form>
</body>

代碼隱藏:

private void HandleReinitialization()
{
    this.ResultsLb.Text = DemandCreationConstants.ResearchDefaultText;
    this.familyDdlSelectedValue = string.Empty;
    this.motiveDdlSelectedValue = string.Empty;
    this.submotiveDdlSelectedValue = string.Empty;
    this.LoadFamilies(true);
    this.LoadMotives(false);
    this.LoadSubmotives(false);
    this.ResultsRpt.DataSource = null;
    this.ResultsRpt.DataBind();
    this.KeywordsSearchHfi.Value = string.Empty;
    this.KeywordsTbx.Text = string.Empty;
    LogServiceInstance.Debug("L'utilisateur " + UserSession.UserLogOn + " a réinitialisé la recherche.");
}

HandleReinitialization 由事件 ReinitializeBtn_Click 啟動

如果您理解正確,您將需要創建 UpdatePanel2 並將任何控件添加到其中,然后在第一個 UpdatePanel1 的按鈕 Click() 方法中調用Update()方法。

UpdatePanel2.Update();

更新:確保將 UpdatePanel2 的 UpdateMode 設置為“Conditional”

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            // Your controls
        </ContentTemplate>
    </asp:UpdatePanel>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM