简体   繁体   English

关闭弹出窗口的Javascript错误

[英]Javascript Error for closing popup

Currently I'm working on ASP.NET project where it's required to have popup. 目前,我正在ASP.NET项目中工作,该项目需要弹出窗口。 I managed to do the part where it takes input from user but stuck when want to close the pop up. 我设法完成了从用户那里获取输入的部分,但是当想要关闭弹出窗口时却卡住了。

Here is the error: 这是错误:

0x800a138f - Microsoft JScript runtime error: 'null' is null or not an object 0x800a138f-Microsoft JScript运行时错误:“ null”为null或不是对象

Below is my code: 下面是我的代码:

    function BlockUI(elementID) {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(function () {
        $("#" + elementID).block({ message: '<table align = "center"><tr><td>' +
   '<img src="html/images/loadingAnim.gif"/></td></tr></table>',
            css: {},
            overlayCSS: { backgroundColor: '#000000', opacity: 0.6
            }
        });
    });
    prm.add_endRequest(function () {
        $("#" + elementID).unblock();
    });
   }
   $(document).ready(function () {

    BlockUI("<%=pnlEdit.ClientID %>");
    $.blockUI.defaults.css = {};
  });


   function Hidepopup() {
    $find("popup").hide();
    return false;
  }

Code in aspx.page:- aspx.page中的代码:-

 <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="return     
  Hidepopup()" />

Managed to find the solution for this problem. 设法找到此问题的解决方案。

Just need to replace this function 只需要替换这个功能

      function Hidepopup() {
      $find("popup").hide();
      return false;
      }

with

      function Hidepopup() {
      $find("<%=popup.ClientID %>").hide();
       return false;
      }

Based on my research, the second function is the proper way to write the function for $find,the first function sometimes may return null value. 根据我的研究,第二个函数是为$ find编写函数的正确方法,第一个函数有时可能返回空值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM