0
我有2個更新面板,第一個帶有鏈接按鈕來打開模式彈出窗口,我意識到必須將這些驗證程序設置爲啓用false,才能彈出。第二個更新面板和麪板一起出現,這些按鈕取消和按鈕確認。在autopostback之前,一切工作正常。但我想知道爲什麼在autopostback之後,取消按鈕甚至不能關閉模式彈出窗口,而且確認按鈕不再有效。ModalPopupExtender在autopostback後無法正常工作
<asp:UpdatePanel ID="uptbl" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:ModalPopupExtender ID="mpe" runat="server"
TargetControlID="btnDummy"
PopupControlID="UpdatePanel1"
BackgroundCssClass="modalBackground"
OkControlID="btnDummy"
CancelControlID="Button2"
BehaviorID="mpeBehavior" />
<input id="btnDummy" runat="server" type="button" style="display: none;" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlLength" runat="server" AutoPostBack="true" onselectedindexchanged="ddlLength_SelectedIndexChanged">
<asp:ListItem>---Select Minutes---</asp:ListItem>
<asp:ListItem Value="60">60</asp:ListItem>
<asp:ListItem Value="120">120</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" InitialValue="---Select Minutes---"
runat="server" ErrorMessage="Minutes is required!"
ControlToValidate="ddlLength" Display="Dynamic"
CssClass="error" Enabled="false" ValidationGroup="reserve">
</asp:RequiredFieldValidator>
<asp:Button ID="btnConfirm" runat="server" Text="Confirm" OnClick="btnConfirm_Click" ValidationGroup="reserve"/>
<asp:Button ID="Button2" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" />
public void DynamicClick(object sender, EventArgs e)
{
UpdatePanel1.Update();
mpe.Show();
RequiredFieldValidator2.Enabled = true;
}
public void btnCancel_Click(object sender, EventArgs e)
{
mpe.Hide();
RequiredFieldValidator2.Enabled = false;
}
protected void ddlLength_SelectedIndexChanged(object sender, EventArgs e)
{
int length = 0, unit = 0;
if (ddlLength.SelectedIndex != 0)
{
length = Convert.ToInt32(ddlLength.SelectedItem.Value);
unit = length/60;
}
RequiredFieldValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
Button2.CausesValidation = false;
}