2016-07-26 77 views
0

我在asp.net中使用模態彈出式擴展器來顯示模態彈出窗口。當我點擊目標按鈕模式彈出顯示成功,如果點擊取消按鈕它也會成功關閉。但我的問題是,當我點擊瀏覽器的後退按鈕再次模式彈出按鈕將顯示,但我不希望顯示模式彈出,請救我出這problem.Code的低於使用asp.net的模態彈出式擴展器

<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=""></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

調用此線在你的頁面加載。

modalpopup.Hide(); 
+0

我試過,但沒有工作.........問題是,後面的代碼甚至不會運行時點擊後退按鈕,頁面從緩存中加載。如果最後一頁加載(回發或不)有一個彈出窗口,它會再次顯示該彈出窗口 –

0

你可以把this.Hide()或在點擊功能取消按鈕,然後modalpopup.Hide()

相關問題