我在asp.net中使用modal popup extender来显示模态弹出窗口。当我成功点击目标按钮模态弹出显示,如果单击取消按钮,它也将成功关闭。但我的问题是,当我再次单击浏览器后退按钮模态弹出按钮将显示但我不想显示模式弹出窗口请带我摆脱这个问题。代码在下面
<asp:Button ID="Button1" runat="server" Text="Edit" CssClass="btndesign" Style="display: none" />
<asp:ModalPopupExtender ID="modalpopup" runat="server" TargetControlID="Button1" CancelControlID="cancel" PopupControlID="panel" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>
<asp:Panel ID="panel" runat="server" Style="background: linear-gradient(to top,#ffffff 0%, #f1f6f9 50%); width: 31%; display: none">
<asp:Button ID="cancel" runat="server" Text="X" Style="float: right; margin-top: 9px; margin-right: 3px; background: #ef5350; border-color: #ef5350; color: #fff; font-size: 11px; padding-top: 3px; padding-bottom: 3px;" />
<h4 style="text-align: left; background-color: #fff; padding: 2%; margin-top: 5px;">Business</h4>
<table>
<tbody>
<tr>
<td>EIN</td>
<td>
<asp:TextBox ID="editein" runat="server" MaxLength="9" ValidationGroup="editgroup" Style="margin-bottom: 10px;"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="editfteein" runat="server" TargetControlID="editein" ValidChars="0123456789"></asp:FilteredTextBoxExtender>
<asp:RequiredFieldValidator ID="editrequired" runat="server" SetFocusOnError="true" ControlToValidate="editein" ErrorMessage="Please Enter EIN Number" Display="None" ValidationGroup="editgroup"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="editvce" runat="server" TargetControlID="editrequired" PopupPosition="Right"></asp:ValidatorCalloutExtender>
<asp:RegularExpressionValidator ID="editexpression" runat="server" SetFocusOnError="true" ControlToValidate="editein" ErrorMessage="EIN Must be of 9 digits" ValidationExpression="^\d{9}$" ValidationGroup="editgroup"></asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="editexpvce" runat="server" TargetControlID="editexpression" PopupPosition="Right"></asp:ValidatorCalloutExtender>
</td>
</tr>
<tr>
<td>Business Name</td>
<td>
<asp:TextBox ID="editname" runat="server" MaxLength="50" ValidationGroup="editgroup" Style="margin-bottom: 10px;"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="editftebusinessname" runat="server" TargetControlID="editname" ValidChars="&#()' -" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom"></asp:FilteredTextBoxExtender>
<asp:RequiredFieldValidator ID="editrfvbusinessname" runat="server" SetFocusOnError="true" ControlToValidate="editname" ErrorMessage="Please enter business name here" Display="None" ValidationGroup="editgroup"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="editvcebusinessname" runat="server" TargetControlID="editrfvbusinessname" PopupPosition="Right"></asp:ValidatorCalloutExtender>
<asp:RegularExpressionValidator ID="editrevbusninessname" runat="server" SetFocusOnError="true" ControlToValidate="editname" ErrorMessage="Please enter valid business name" ValidationExpression="^[a-zA-Z0-9#&()'\s-]{4,75}$" Display="None" ValidationGroup="editgroup"></asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="editvcerevbusninessname" runat="server" TargetControlID="editrevbusninessname" PopupPosition="Right"></asp:ValidatorCalloutExtender>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:CheckBox ID="changeaddress" runat="server" Text="Address changed from last filing" Style="margin-bottom: 10px;" />
</td>
</tr>
<tr>
<td>Address Line</td>
<td>
<asp:TextBox ID="editaddress" runat="server" MaxLength="50" Style="margin-bottom: 10px;"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="editfteaddress" runat="server" TargetControlID="editaddress" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom" ValidChars=" -/"></asp:FilteredTextBoxExtender>
<asp:RequiredFieldValidator ID="editrfvaddress" runat="server" ControlToValidate="editaddress" SetFocusOnError="true" ErrorMessage="Please enter address" Display="None" ValidationGroup="editgroup"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="editvceaddress" runat="server" TargetControlID="editrfvaddress" PopupPosition="Right"></asp:ValidatorCalloutExtender>
<asp:RegularExpressionValidator ID="editrevaddress" runat="server" ControlToValidate="editaddress" SetFocusOnError="true" ErrorMessage="Please enter valid address" Display="None" ValidationExpression="[A-Za-z0-9]( ?[A-Za-z0-9\-/])*" ValidationGroup="editgroup"></asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="editrevvceaddress" runat="server" TargetControlID="editrevaddress" PopupPosition="Right"></asp:ValidatorCalloutExtender>
</td>
</tr>
<tr>
<td>Address Line 2</td>
<td>
<asp:TextBox ID="editadd2" runat="server" MaxLength="50" Style="margin-bottom: 10px;"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="editfteaddress2" runat="server" TargetControlID="editadd2" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom" ValidChars=" -/"></asp:FilteredTextBoxExtender>
</td>
</tr>
<tr>
<td>City</td>
<td>
<asp:TextBox ID="editcity" runat="server" MaxLength="30" Style="margin-bottom: 10px;"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="editftecity" runat="server" TargetControlID="editcity" FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom" ValidChars=" "></asp:FilteredTextBoxExtender>
<asp:RequiredFieldValidator ID="editrfvcity" runat="server" ControlToValidate="editcity" ErrorMessage="Please enter city name" SetFocusOnError="true" ValidationGroup="editgroup" Display="None"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="editvcecity" runat="server" TargetControlID="editrfvcity" PopupPosition="Right"></asp:ValidatorCalloutExtender>
</td>
</tr>
<tr>
<td>State</td>
<td>
<asp:TextBox ID="txtState" runat="server" CssClass="txtbox" ValidationGroup="BusinessDetails"
Visible="false" MaxLength="30"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="fteState" runat="server" TargetControlID="txtState"
FilterType="LowercaseLetters,UppercaseLetters,Custom" ValidChars=" ">
</asp:FilteredTextBoxExtender>
<asp:RequiredFieldValidator ID="rfvState" runat="server" ControlToValidate="txtState"
ErrorMessage="Please enter your state here" Display="None" ValidationGroup="BusinessDetails">
</asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="vce_rfvState" runat="server" PopupPosition="Right"
TargetControlID="rfvState" HighlightCssClass="errorField">
</asp:ValidatorCalloutExtender>
<asp:RegularExpressionValidator ID="revState" runat="server" ControlToValidate="txtState"
SetFocusOnError="True" Display="None" ErrorMessage="Please enter valid state name"
ValidationExpression="[A-Z,a-z ]{1,50}" ValidationGroup="BusinessDetails">
</asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="vce_revState" runat="server" PopupPosition="Right"
TargetControlID="revState" HighlightCssClass="errorField">
</asp:ValidatorCalloutExtender>
<asp:DropDownList ID="ddlState" runat="server" CssClass="txtbox" Style="width: 300px">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvStateddl" runat="server" ControlToValidate="ddlState"
ErrorMessage="Please select state" InitialValue="0" Display="None" ValidationGroup="BusinessDetails">
</asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="vce_rfvStateddl" runat="server" PopupPosition="Right"
TargetControlID="rfvStateddl" HighlightCssClass="errorField">
</asp:ValidatorCalloutExtender>
</td>
</tr>
<tr>
<td>Country</td>
<td>
<asp:DropDownList ID="editcontry" runat="server" CssClass="txtbox" Style="margin-bottom: 10px; width: 300px"
AutoPostBack="true" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged">
<asp:ListItem Text="United States of America" Value="US"></asp:ListItem>
<asp:ListItem Text="Canada" Value="CA"></asp:ListItem>
<asp:ListItem Text="Mexico" Value="MX"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Zip</td>
<td>
<asp:TextBox ID="txtZip" runat="server" CssClass="txtbox" ValidationGroup="BusinessDetails"
MaxLength="12"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="fteZip" runat="server" TargetControlID="txtZip"
FilterType="LowercaseLetters,UppercaseLetters,Numbers,Custom" ValidChars=" "
Enabled="false">
</asp:FilteredTextBoxExtender>
<asp:FilteredTextBoxExtender ID="fteZipUS" runat="server" TargetControlID="txtZip"
FilterType="Numbers" Enabled="false">
</asp:FilteredTextBoxExtender>
<asp:RequiredFieldValidator ID="rfvZip" runat="server" ControlToValidate="txtZip"
ErrorMessage="Please enter your zip code here" Display="None" ValidationGroup="BusinessDetails">
</asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="vce_rfvZip" runat="server" PopupPosition="Right"
TargetControlID="rfvZip" HighlightCssClass="errorField">
</asp:ValidatorCalloutExtender>
<asp:RegularExpressionValidator ID="revZip" runat="server" ControlToValidate="txtZip"
SetFocusOnError="True" Display="None" ErrorMessage="Please enter valid zip code"
ValidationExpression="[0-9]{5}(([0-9]{4}))?" ValidationGroup="BusinessDetails">
</asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="vce_revZip" runat="server" PopupPosition="Right"
TargetControlID="revZip" HighlightCssClass="errorField">
</asp:ValidatorCalloutExtender>
</td>
</tr>
</tbody>
</table>
<div style="background: #5f9fa1; padding: 2%;">
<asp:CheckBox ID="updatemaster" runat="server" Text="Also Update Master Business Info" required=""></asp:CheckBox>
<asp:Button ID="updateprocess" runat="server" Text="Update & Process" />
</div>
</asp:Panel>
答案 0 :(得分:0)
在页面加载中调用此行。
modalpopup.Hide();
答案 1 :(得分:0)
您可以将this.Hide()
或点击功能设为取消按钮,然后modalpopup.Hide()