html - Setting a panel to visible using javascript -


how can make <asp:panel> visible using javascript?

i have done following error (cannot read property style of null)

 <asp:panel runat="server" id="pannonafricancountries" visible="false">  var pannonafricadropdown = document.getelementbyid("pannonafricancountries") if (dropdownfirst == "yes") {     pannonafricadropdown.style.visibility = "visible"; } 

the visible="false" on asp.net control have result not render control on page.

what try here render it, css style have hidden user until using javascript show it. archive not use visible, set style or css panel.

<asp:panel id="panelid" runat="server" visible="true" style="visibility:hidden" > content here...     </asp:panel> 

the asp.panel render div , html on page as:

<div id="panelid" style="visibility:hidden"> content here...     </div> 

and because not know sure how id rendered. use panelid.clientid , final javascript code be:

var pannonafricadropdown = document.getelementbyid("<%=panelid.clientid%>"); if (dropdownfirst == "yes" && pannonafricadropdown) {     pannonafricadropdown.style.visibility = "visible"; } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -