如何在没有asyncpostback的情况下刷新UpdatePanel

时间:2015-04-28 11:53:41

标签: c# asp.net ajaxcontroltoolkit

我有一个弹出窗口,其中包含formview和一个保存按钮。当我点击弹出的保存按钮时,我想刷新更新面板。如果没有asyncpostback,我怎么能这样做?谢谢你的帮助

<asp:ImageButton ID="imgSavePhoto" runat="server" ImageUrl="Images/PhotoCompIcons/32x32/Document2.png" ImageAlign="AbsMiddle" ToolTip="Yeni Kayıt" />

        <asp:ModalPopupExtender ID="mpeInsert" runat="server" TargetControlID="imgSavePhoto" CancelControlID="btnClose" PopupControlID="pnlModalPopup" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>

    <asp:Panel ID="pnlModalPopup" runat="server" CssClass="modalPopup" align="center" Style="display: none">
       <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                       <ContentTemplate>
                            <div class="CloseButton">
                                <asp:ImageButton ID="btnClose" runat="server" ImageUrl="~/dialog_close.ico" ToolTip="Kapat" ImageAlign="AbsMiddle" />
                                </div>
                                <div class="RecordType">
                                    <asp:Label ID="lblRecordTypeName" runat="server" Font-Size="Medium" Font-Bold="true"></asp:Label>
                                </div>
                                <asp:FormView ID="fvCompPartPhotos" runat="server" DataKeyNames="ID" DataSourceID="odsCompPartPhotos" DefaultMode="Insert" EnableModelValidation="True" OnDataBound="fvCompPartPhotos_DataBound1" OnItemCommand="EditPhotoCommands" Style="margin-left: 0px">
                                    <InsertItemTemplate>
                                        //some codes
                                    </InsertItemTemplate>
                                </asp:FormView>
                            </ContentTemplate>
                        </asp:UpdatePanel>
          <div class="PhotoEditButtons">
                            <asp:ImageButton ID="imgClear" runat="server" ImageUrl="Images/PhotoCompIcons/32x32/Document2.png" ImageAlign="AbsMiddle" ToolTip="Yeni Kayıt" OnClick="imgClear_Click" />&nbsp;&nbsp;|&nbsp;
                         <asp:ImageButton ID="imgSaveNew" runat="server" ImageUrl="Images/PhotoCompIcons/32x32/Save.png" ImageAlign="AbsMiddle" ToolTip="Kaydet" OnClick="imgSaveNew_Click" />
 <asp:AsyncFileUpload ID="fuPhoto" runat="server" />
                        </div>

1 个答案:

答案 0 :(得分:1)

如上所述,您希望在没有UpdatePanel的情况下刷新asyncpostback

在这里: -

<强> 解决方案

YourUpdatePanelId.Update();

在这里查看documentation

button click上,您可以轻松设置

protected void Button1_Click(object sender, EventArgs e)
{
    if (LastUpdate.AddSeconds(5.0) < DateTime.Now)
    {
        UpdatePanel1.Update();
        LastUpdate = DateTime.Now;
    }
}

您需要根据自己的要求进行自定义,这就是...... !!!!