PopUp div没有使用Javascript函数显示(JavaScript运行时错误:无法获取未定义或空引用的属性'样式') [英] PopUp div is not displaying by using Javascript function (JavaScript runtime error: Unable to get property 'style' of undefined or null reference)

查看:111
本文介绍了PopUp div没有使用Javascript函数显示(JavaScript运行时错误:无法获取未定义或空引用的属性'样式')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Javascript函数不显示PopUp div

----------------------- -------------------------------------

Js函数

-------------------

PopUp div is not displaying by using Javascript function
------------------------------------------------------------
Js function
-------------------

function btnExportLE_click() {
        debugger;
        document.getElementById('<%=dvladen.ClientID %>').style.display = "block";
        document.getElementById('<%=dvHider.ClientID %>').style.display = "block";
        return false;
    }





风格

-----



Style
-----

.dvladen
 {
     z-index: 2;
     position: absolute;
     width: 599px;
     height: 398px;
     border-width: 0px;
     top: 280px;
     left: 573px;
     background-color: White;
}





DIV

--------



DIV
--------

<div id="dvladen" runat="server" class="popup" visible="false" >
<p> HAIII</p>
</div>
<div id="dvHider" runat="server" class="hider">
</div>







然后我在Button Click中调用了Js函数/>


< asp:Button ID =btnExportLErunat =serverclass =btnNewText =Export LE

OnClientClick = return btnExportLE_click(); />



PAge Load

----------

dvladen.Style [display] =none;





但它显示的错误如



JavaScript运行时错误:无法获取未定义或空引用的属性样式





请帮我解决这个问题..





问候

Jithesh




Then I called Js function in Button Click

<asp:Button ID="btnExportLE" runat="server" class="btnNew" Text="Export LE"
OnClientClick="return btnExportLE_click();" />

PAge Load
----------
dvladen.Style["display"] = "none";


But It Showing An error like

JavaScript runtime error: Unable to get property 'style' of undefined or null reference


please help me to solve this..


Regards
Jithesh

推荐答案

请检查document.getElementById('<%= dvladen.ClientID%>')是否为null。这就是风格无法识别的原因。如果您没有使用母版页,那么您可以简单地使用没有客户端ID的控件ID。
Please check document.getElementById('<%=dvladen.ClientID %>') is throwing null. That's why style is not recognize . if you are not using master page then you can simply use Id of control without client Id.


这篇关于PopUp div没有使用Javascript函数显示(JavaScript运行时错误:无法获取未定义或空引用的属性'样式')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆