开发者

how to set masterpage dom element in contentpage with javascript

开发者 https://www.devze.com 2023-03-31 15:00 出处:网络
a div in asp.net masterpage,i want hide it in one of its content page ,so I add this js at the end of content page

a div in asp.net masterpage,i want hide it in one of its content page ,so I add this js at the end of content page

if (document.getElementById('sitemap'))
189 document.getElementById('sitemap').display = "none"; 

div sitemap in materpage, when i debug this js,document.getElementById('sitemap') run ok,but it can't be hiden .why? if I want set materpage's dom element style in content page,how to 开发者_Python百科do this? thanks.


you're missing the style-member:

document.getElementById('sitemap').style.display = "none"; 


If it's a .Net control(ASP:Panel), leave a hook in your Masterpage to access it, otherwise Dr.Molle's answer is what you need:

Masterpage:

function HideSiteMap()
{
   document.getElementById('" + sitemap.ClientID + "').style.display = "none";               
}

Contentpage:

Call the function.

0

精彩评论

暂无评论...
验证码 换一张
取 消