admin管理员组文章数量:1334168
I am having an aspx page with a panel. I am using the panel as to show a messagebox. The panel id is "panMessage". The panel contains a button label "Hide". I am showing the panel using code behind but need to close the panel with JS when user clicks on Hide button. I have attached the following code with onclick event of the button -
onclick="javascript:(<%=panMessage.ClientID%>).style.visibility='hidden';"
the click event works perfectly in IE but not in FireFox. I have googled and changed the code as -
onclick="javascript:(<%=panMessage.ClientID%>).style.display='none';"
but still the code is not working i.e. the panel is not going to hide in FireFox although it works in IE using this new code also.
Could someone guide me whats wrong i have done?
Thanks for your cooperation.
I am having an aspx page with a panel. I am using the panel as to show a messagebox. The panel id is "panMessage". The panel contains a button label "Hide". I am showing the panel using code behind but need to close the panel with JS when user clicks on Hide button. I have attached the following code with onclick event of the button -
onclick="javascript:(<%=panMessage.ClientID%>).style.visibility='hidden';"
the click event works perfectly in IE but not in FireFox. I have googled and changed the code as -
onclick="javascript:(<%=panMessage.ClientID%>).style.display='none';"
but still the code is not working i.e. the panel is not going to hide in FireFox although it works in IE using this new code also.
Could someone guide me whats wrong i have done?
Thanks for your cooperation.
Share Improve this question edited Nov 27, 2009 at 13:42 DOK 32.9k8 gold badges63 silver badges93 bronze badges asked Nov 27, 2009 at 13:33 IrfanRazaIrfanRaza 3,05817 gold badges65 silver badges90 bronze badges 1- Show us the rendered HTML --> run your page, view source, copy/paste relevant HTML. – cllpse Commented Nov 27, 2009 at 13:34
4 Answers
Reset to default 4It seems to me that the problem lies with (<%=panMessage.ClientID%>)
.
onclick="(<%=panMessage.ClientID%>).style.display='none';"
When rendered would give something like:
onclick="(panMessage_1).style.display='none';"
You should put something like:
onclick="document.getElementById('<%=panMessage.ClientID%>').style.display='none';"
First of all, visibility hidden
and display none
are not the same. The former will make the element consume the same space as it would have, if it would've been visible, whereas the latter won't. display: none
is synonymous to visibility: hidden; position: absolute;
Other than that, your problem is probably due to the way you access your element. Try changing to the following:
onclick="document.getElementById('<%=panMessage.ClientID%>').style.display='none';"
Use
document.getELementById ( "<%=panMessage.ClientID%>" )
to retrieve the element and then try setting the display or visibility attribute.
Set the display attribute to none so that the control won't take the space.
We'd really need to see the actual HTML output to be able to debug it for you.
The correct output should look something like this:
onclick="document.getElementById('panMessage').style.display='none';"
Note that you don't need javascript:
in the event handlers.
本文标签: aspnetstylevisibility not working in FireFoxStack Overflow
版权声明:本文标题:asp.net - style.visibility not working in FireFox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742365241a2461159.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论