开发者

How can I make my Modal Popup Extender Modal? (Disable background)

开发者 https://www.devze.com 2022-12-08 03:53 出处:网络
I added a simple ajax modal popup extender to my asp.net application. It appears and functions correctly, however unl开发者_Python百科ike the sample on the ajax toolkit website, it does not disable/d

I added a simple ajax modal popup extender to my asp.net application.

It appears and functions correctly, however unl开发者_Python百科ike the sample on the ajax toolkit website, it does not disable/dim the rest of the page. What do I have to do to achieve this effect?

 <asp:Button ID="btnSaveAndClose" runat="server" Text="Save" 
                onclick="btnSaveAndClose_Click"/>

                <cc1:ModalPopupExtender 
                BackgroundCssClass="modalBackground" 
                DropShadow="true" 
                OkControlID="btnOk" 
                CancelControlID="btnOk" 
                runat="server" 
                PopupControlID="pnlClientSaved" 
                id="ModalPopupExtender1" 
                TargetControlID="btnSaveAndClose"
                 /> 

<asp:Panel ID="pnlClientSaved" runat="server" CssClass="modalPopup" style="display:none;" Width="300px" Height="200px"> 
Client Saved!
<br /><br /> 
<asp:Button ID="btnOk" runat="server" Text="Ok" /> 
</asp:Panel> 


You should write an appropriate style in "modalBackground" css class. Appropriate property was already set in you code:

BackgroundCssClass="modalBackground" 

Here is listing of this class from example page:

.modalBackground 
{
    background-color:Gray;
    opacity:0.7;
}


.modalBackground
{
    background-color:Gray ;
    filter:alpha(opacity=30);

} 


The answer does not stop the scrolling in the background, which IMO is a true disabling of the background.

I did it using this...

Wrap your ContentPlaceHolder in a <DIV id="wrapper">

And using Jquery... in your main body, use this code with the referenced CSS classes in your objects.

So CSSClass="popupOK" in your label or control inside the modalpopupextender, and CSSClass="promoVisible" in your OK or CANCEL buttons that are supposed to remove the popup.

$(document).ready(function () {
    //had to set position:fixed to work on iPad and other mobile    
    $('.popupOk').click( function(){
      $('#wrapper').css('overflow', 'auto');
      $('#wrapper').css('position', 'inherit');
      //  alert("ok clicked");
    });
    // if the popup is visible, fix the overflow so the
    // background doesn't scroll, only the popup window
    if($('.promoVisible').is(':visible')){
      $('#wrapper').css('overflow', 'hidden');
      $('#wrapper').css('position', 'fixed');
    } else{
      $('#wrapper').css('overflow', 'auto');
      $('#wrapper').css('position', 'inherit');
    }
)}
0

精彩评论

暂无评论...
验证码 换一张
取 消