Created a simple application for saving data. I want to:
1. Confirm that the user wants to save the data (ConfirmButtonExtender) 2. Notify the user that the data was saved successfully (ModalPopupExtender with a panel)aspx code:
<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="PanelSaveConfirmPopup"
BehaviorID="ModalSaveConfirm" TargetControlID="PanelSaveConfirmPopup" DropShadow="true"
CancelControlID="btnSaveConfirmedPopupOk">
</asp:ModalPopupExtender>
<asp:Panel ID="PanelSaveConfirmPopup" run开发者_运维知识库at="server" Style="display: none;" BorderColor="Black"
BorderStyle="Solid" BorderWidth="1px" Width="300px" Height="150px" BackColor="White"
ForeColor="Black">
<table width="99%">
<tr>
<td height="30">
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="Label19" runat="server" Text="Your data has been saved."></asp:Label>
</td>
</tr>
<tr>
<td height="45">
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnSaveConfirmedPopupOk" runat="server" Text="Okay" />
</td>
</tr>
</table>
</asp:Panel>
<asp:Button ID="btnSave" runat="server" Text="Save" />
<asp:ConfirmButtonExtender ID="btnSave_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure you want to save this?"
Enabled="True" TargetControlID="btnSave">
</asp:ConfirmButtonExtender>
</asp:Content>
code behind:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnSave_Click(sender As Object, e As System.EventArgs) Handles btnSave.Click
' Pretend to save data here
ModalPopupExtender1.Show()
End Sub
End Class
I get both of the popups - my problem is that the close button on the ModalPopupExtender panel is not closing the modalpopup. Any ideas? Thanks!
I got some hints from link that got it working. Will post the working code shortly (I think I have wait 24 hours to answer my own question). The trick was to create a dummy button. The dummy button has to be asp.net visible = true but it can be hidden in html using Style="display: none"
The working code is:
<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Button ID="btnSave" runat="server" Text="Save" />
<asp:ConfirmButtonExtender ID="btnSave_ConfirmButtonExtender" runat="server" ConfirmText="Are you sure you want to save this?"
Enabled="True" TargetControlID="btnSave">
</asp:ConfirmButtonExtender>
<!-- We have to have a dummy control to hold the start event we handle in code behind -->
<asp:Button ID="MpeFakeTarget" runat="server" CausesValidation="False" Style="display: none" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="PanelSaveConfirmPopup"
BehaviorID="ModalSaveConfirm" TargetControlID="MpeFakeTarget" DropShadow="true"
CancelControlID="btnSaveConfirmedPopupOk">
</asp:ModalPopupExtender>
<asp:Panel ID="PanelSaveConfirmPopup" runat="server" Style="display: none;" BorderColor="Black"
BorderStyle="Solid" BorderWidth="1px" Width="300px" Height="150px" BackColor="White"
ForeColor="Black">
<table width="99%">
<tr>
<td height="30">
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="Label19" runat="server" Text="Your data has been saved."></asp:Label>
</td>
</tr>
<tr>
<td height="45">
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnSaveConfirmedPopupOk" runat="server" Text="Okay" />
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>
I am not sure if I like the fact that the two popups are different or not? Granted first is asking pers
精彩评论