English 中文(简体)
从客户端隐藏Modal弹出窗口扩展程序
原标题:Hiding Modal popup extender from client side

我需要使用JavaScript在客户端隐藏模态弹窗。

如果我使用

$find( ModalPopupExtender1 ).hide();

为了隐藏它,它报错了。

null 是 null 还是不是一个对象

最佳回答

有两个选项来解决这个问题:

  1. 将modalpopup的ID更改为ModalPopupExtender1

  2. 将你的脚本更改为以下内容:

    $find( <%= ModalPopupExtender1.ClientID%> ).hide();
    
问题回答

解决此问题有两个选择:

  1. 将行为ID更改/添加到模态弹出窗口,并命名为ModalPopupExtender1。 (Traditional Chinese: 將行為ID更改/添加到模態彈出窗口,並命名為ModalPopupExtender1。)

  2. 把你的脚本改成这样:

    $find( ModalPopupExtender1 ).hide();
    

听起来$find调用可能找不到行为。 你能改变代码吗:

var behavior = $find( ModalPopupExtender1 );
var undefined;
if (behavior !== undefined)
   alert("found");
else
   alert("not found");

有两个解决办法:

将一个 behaviorID 添加/更改给弹出窗口,并将其命名为 ModalPopupExtender1

Change your script to this: $find( ModalPopupExtender1 ).hide();

I was having no luck with any of the above techniques, nor any others I found on the Web. Something that DOES work for me is to call

__doPostBack("xxx", 0);

This causes a proper page reload and the popup does NOT come back. Note that my code-behind does not explicitly look for or handle the "xxx" param, it just lets the postback reload the page.

我承认,OP可能希望关闭弹窗而不刷新页面,但在我这种情况下,我确实需要刷新,所以这对我有效。





相关问题
Getting rid of Microsoft AJAX

We wrote a couple of controls using Microsoft AJAX (cs class + js class). Now I m thinking about getting rid of it (just use jQuery), as it is bloated and we don t use UpdatePanel. My question is: how ...

ASP.NET Ajax 4 and Microsoft Ajax library definitions

I undestand that is former for Web Forms ASP.Net only , latter ( currently preview 6 ) suitable for both - classic and MVC. Would it be possible to give a brief description/usage for each. By ASP.NET ...

ASP.NET Rich UI - What do you use? [closed]

I m looking for feedback on what other people use on their ASP.NET projects to provide a rich user interface experience while still remaining as productive as possible. I m developing an ASP.NET 3.5 ...

CollapsiblePanelExtender collapses on link hover

I am trying to use an CollapsiblePanelExtender to make some dropdown menus and am having some problems when hovering over links - can anyone help me out... By the way I do want to keep the ...

热门标签