ASP.NET and Master page Divs

Soldato
Joined
23 Oct 2002
Posts
4,153
Location
_
I'm looking to show or hide portions of navigations by hiding their container divs in .net, and my navigation is in a master page.

How the hell can I do this without using findControl in every single page I create to show / hide the relevant Divs?

I know you can set the visibility of Divs within the aspx portion of a content page, but what I want to do is to set the visibility of a master page div from true to false using a function that's within the master page.

So within my content page, I just want to say:

Code:
divViewable("divName",false)

Any thoughts?
 
Having you tried putting that in a master page and calling the element within the masterpage's code-behind?

I just get no intellisense, and it tells me I haven't declared it.
 
My problems continue, although it might be worth me providing a wider scope as to why I'm trying to do what I'm doing.

I have a HTML page that has a navigation that's using CSS heavily.

http://www.karl0s.com/images/misc/siteLayout.jpg

The navigation is the left bar.

I tried using Master pages, but there's a trick to this navigation that is proving difficult to get around in .NET.

I put the header and navigation in the master page, and then used content placeholders for the main content. This works okay, but I have to change states on the navigation depending what content page I am on. If I am on the homepage, the css class for the home page button in the navigation must change to a different class. Also, the menu has sub-sections that must expand and contract depending on what section of the site I am on.

This sort of thing has similarities with the tree structure control.

Each list of items is in a div.

<div headerbutton> Title</div>

<div menuList>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>

When I click on a seperate section, menuList must be hidden.



The way I wanted to get around this was to have a hideNavigation function sat in the Master page called by the content page that'd hide all the menu divs, and then my page would call the relevant div to show via a function showMenuItem() which'd also be in the master page. I thought this was a good way of laying it out, but I can't access any div items' properties within the master page from the master page's code-behind.

I thought of using a user control for a header and a user control for navigation, but it's a bit of a rubbish way of doing it from my point of view.


I'm trying to do all this in ASP.NET (VB) - What options do you think I have? I can't believe it's so difficult to do what seems like an elementary menu system in .NET that I would have no trouble doing in Classic ASP!

Any help is *extremely* appreciated.

Thanks,

Karl.
 
Unfortunately it doesn't help at all - Not your fault because I didn't mention that I'd already tried that. I've put a runat="server" attribute in each of the Div tags that I've tried to access, and I've also tried replacing those Divs with panels instead. Neither allows me to get at the objects; in both cases it tells me that the variable needs declaring, which prevents my page from loading.

Rather than intellisense not picking it up, it's not working at all.

Could you try doing this yourself and see if you experience the same problems? Even a simple experiment should do the trick, as I simply cannot get this to work! :(
 
elkdanger helped me solve this by pointing out something blindingly obvious - I had somehow managed to remove the header for the master page's aspx that ties it to the code-behind. A few minor fixes later, and hey-presto! Fixed!

Thanks for your input. :)
 
Back
Top Bottom