ModalPopupExtender and z-index

家住魔仙堡 提交于 2019-12-10 11:08:21

问题


How can I change ASP.NETAJAX ModalPopupExtender z-index. By default it is 100001. Thanks.


回答1:


I use this function:

  function ShowModalPopup(modalPopupId, zIndex) {

    try {
      if (modalPopupId == null) throw new Error(0, 'Incorrect value of param modalPopupId!');

      var modalPopupBehavior = $find(modalPopupId);
      if (modalPopupBehavior == null) throw new Error(0, 'Not found modal popup ' + modalPopupId + '!');

      zIndex = typeof (zIndex) != 'undefined' ? zIndex : null;

      if (zIndex != null) {
        modalPopupBehavior._backgroundElement.style.zIndex = zIndex;
        modalPopupBehavior._foregroundElement.style.zIndex = zIndex + 1;
      }

      modalPopupBehavior.show();
    }
    catch (ex) {
      alert('Exception in ShowModalPopup: ' + ex.message);
    }
  }

and its call:

  ShowModalPopup('<%= modalpopup.ClientID %>', 20001);



回答2:


I assign a CSS class to the panel my modalpopupextender is assigned to (PopupControlID), and put somthing like:

.ModalSelect 
{
   z-index:70000 !important;
   /*other css*/ 
}



回答3:


You can hook up a handler to the shown event on the modalpopup that allows you to set the zIndex:

function pageLoad()
{
    var popup = $find('ModalPopupClientID');
    popup.add_shown(SetzIndex);
}

function SetzIndex(sender,args)
{
    sender._container.style.zIndex=9990001;
}


来源:https://stackoverflow.com/questions/1487977/modalpopupextender-and-z-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!