2012-02-15 75 views
0

包括jQuery的1.3.2.min.js和这里blockUI-2.15.0.js

<script type="text/javascript"> 

    $(document).ready(function() { 
     $(".noButton").click(function(e) { 
      e.preventDefault(); 

      $.blockUI({ message: $('#AreYouSureMessage') }); 

     }); 

     $('.noButtonPopup').click(function() { 

      doNoPostBack(); 

      return true; 
     }); 

     $('.yesButtonPopup').click(function() { 

      doYesPostBack(); 

      return true; 
     }); 

$ .blockUI.defaults.overlayCSS.opacity = 0.7;

$ .blockUI.defaults.css.width ='500px';

$ .blockUI.defaults.css.border ='1px solid#000000';

$ .blockUI.defaults.css.height ='700px';

$ .blockUI.defaults.fadeOut = 0;

注:我收到错误,如下面的IE

“$ .blockUI.defaults”为空或不是对象

+1

您是否正确包含了blockui? – 2012-02-15 19:39:41

+0

嗨安德鲁·惠特克,请检查修改代码 – 2012-02-21 14:00:05

+1

@NikhilPadmanabhan您是否包含完整的代码?你似乎错过了'$(document).ready(function(){'方法。 – GregL 2012-02-21 14:12:53

回答

2

我们只是面临着同样的问题,在我们的内容页面的一个(网络形成)。与同一主页相关的其他内容页面运行良好。

其实我们已经在主页面中包含了jQuery.js文件的引用,但对jQuery.js的同样引用再次被包含在内容页面中。这导致错误消息“$ .blockUI.defaults'为空或不是对象”。

这也意味着,即使您有在任何.aspx页面中错误地引用了jQuery.js文件,您可能会遇到类似的错误消息。

希望这可能有所帮助。

+0

你救了我的生命 – crab 2013-10-02 06:56:19

+0

我的太结束了:)谢谢 – suds 2014-12-23 07:44:04

0

我对这个问题的解决方案是把所有的jQuery参考文件放在一起放在同一个文件夹中。 并且还检查所有jquery文件的路径是否正确(../Script/jquery.BlockUI.js)。

notice on ../ 


Also check for the same reference to jQuery.js was included in the content page once again. 

Ref Link for 
http://amitchandnz.wordpress.com/2010/08/24/jquery-blockui-using-animated-image/ 

To add BlockUI for Masterpage so that the entire site can perform loading panel when postback 

###################################################################################### 
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head runat="server"> 
    <title></title> 
    <script type="text/javascript" src="../Scripts/jquery/jquery-1.9.1.js"></script> 
    <script type="text/javascript" src="../Scripts/jquery/jquery-ui.js"></script> 
    <link rel="stylesheet" type="text/css" href="Scripts/jquery/jquery-ui.css" /> 
    <script src="../Scripts/jquery/jquery.blockUI.js" type="text/javascript"></script> 

    <script type="text/javascript"> 
function BlockUI(elementID) { 
      var prm = Sys.WebForms.PageRequestManager.getInstance(); 
      prm.add_beginRequest(function() { 
       $("#" + elementID).block({ message: '<table><tr><td>' + '<img src="../Scripts/jquery/ajax-loader.gif"/></td></tr></table>', 
        css: {}, 
        overlayCSS: { backgroundColor: '#FFFFFF', opacity: 0.6, border: '1px solid #000000' } 
       }); 
      }); 
      prm.add_endRequest(function() { 
       $("#" + elementID).unblock(); 
      }); 
     } 
     $(document).ready(function() { 
      BlockUI("divMain"); 
      $.blockUI.defaults.css = {}; 
     }); 



    </script> 

    <asp:ContentPlaceHolder ID="HeadContent" runat="server"> 
    </asp:ContentPlaceHolder> 
</head> 
<body> 
    <form runat="server"> 
    <asp:UpdatePanel ID="ajaxUpdatePanel" runat="server"> 
         <ContentTemplate> 
          <div id="divMain"> 
           <asp:ContentPlaceHolder ID="MainContent" runat="server"/> 
          </div> 
         </ContentTemplate> 
        </asp:UpdatePanel> 

    </form> 
</body> 
</html> 

###################################################################################### 







**Download link for jquery.BlockUI.js** 

http://jquery.malsup.com/block/#download 

**Download link for jquery core** 

http://jquery.com/download/ 

**URL for alternatre loading Icon** 

http://www.ajaxload.info/ 


Hope this may help.