ModalPopupExtender and z-index

2019-05-26 19:06发布

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

3条回答
干净又极端
2楼-- · 2019-05-26 19:27

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楼-- · 2019-05-26 19:34

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);
查看更多
虎瘦雄心在
4楼-- · 2019-05-26 19:48

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;
}
查看更多
登录 后发表回答