0
我在asp.net中的服務器端按鈕單擊過程中,使用ajax模式彈出擴展程序顯示了一條確認消息。顯示確認信息後,當我點擊瀏覽器的後退按鈕時,同樣會彈出確認信息再次出現。當我點擊瀏覽器的後退按鈕時如何隱藏彈出消息?如何在點擊瀏覽器後退按鈕時隱藏ajax模式彈出式擴展器?
我的代碼是
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:Panel runat="server" ID="pnlInterfaceDetails" Style="display: none;">
<asp:Label ID="Label1" runat="server" Text="Confirmation Message" Font-Bold="true"
Font-Size="10pt" Style="color: White; font-family: Sans-Serif Verdana Arial"></asp:Label>
<table>
<tr style="height: 35px">
<td colspan="2">
<b><span style="color: Black;">Data Saved Successfully.</span></b>
</td>
</tr>
<tr style="height: 35px">
<td align="center" colspan="2">
<asp:Button runat="server" ID="btnConfirmClose" Text="Close" ToolTip="Close" Width="65px"
OnClick="btnConfirmClose_Click" CssClass="buttonOrangebg" />
</td>
</tr>
</table>
</asp:Panel>
<asp:ModalPopupExtender runat="server" ID="mpeInterfaceDetails" TargetControlID="btnShowPopup"
BackgroundCssClass="modalBackground" PopupControlID="pnlInterfaceDetails" />
</div>
origin1tech:感謝您的回覆。此代碼無法正常工作。請爲此問題提供任何其他解決方案。我在保存操作過程中顯示了這個彈出消息。保存數據後,我想通過瀏覽器的後退按鈕點擊回到上一頁。 – RGS
不知道你的應用程序,但上述確實可以隱藏模式。我很確定。您也可以使用「卸載」事件。因爲您是「視圖狀態」,因此使用webforms將保留所有數據以便保存,然後使用back至少在大多數情況下是一個糟糕的主意。爲什麼?因爲你最終可能會有重複的帖子。通常你會做的是重定向。 Response.Redirect('/ your url here'); – origin1tech
當使用後退按鈕時,頁面會記住viewstate,正如我所說的那樣,爲了防止最後一個狀態,您必須使用viewstate或添加會話var或其他東西來檢測這是第二次擊中頁面(例如後退按鈕)。如果你想嘗試讓我知道,我會用一個使用會話或自定義視圖狀態的例子進行編輯。 – origin1tech