SleeplessKnight
SleeplessKnight

Reputation: 2185

how to set masterpage dom element in contentpage with javascript

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 do this? thanks.

Upvotes: 1

Views: 561

Answers (2)

rick schott
rick schott

Reputation: 21117

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.

Upvotes: 1

Dr.Molle
Dr.Molle

Reputation: 117334

you're missing the style-member:

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

Upvotes: 2

Related Questions