简体   繁体   中英

How to show or hide left content of content pages through master page in asp.net

I am working on an asp.net C# webforms project which has master/content pages. While some content pages will have a list of page specific links, say in an asp.net panel on their left side, the rest will not have it. I am wondering what will be best way to do it. For this, the content page which will have the left nav links, will communicate with the master page so that the master page will show or hide the left nav panel, and the content page will populate it. Having the left nav as part of the content page itself was easier, as I was displaying it as follows:

When the content page had the left nav:

<div class="row">
  <div class="col-md-3">
    --Left nave goes here--
  </div>
  <div class="col-md-9">
    --Rest of the contents go here--
  </div>
</div>

When the content page didn't have the left nav:

<div class="content">   
  --All the contents go here--
</div>

Any good approach to do it through the master page will be greatly appreciated!

One simple approach may be to just use Nested Master Pages . So you would have your main master page that has the bulk of your HTML, then create two more master pages (LeftNav.master and NoLeftNav.master, for example) that use that main master page. You would then choose for each content page which master page you want, the one with left nav or without.

Good luck!

I have created a two column layout using Bootstrap. Then I either hide or show the left column using jquery as described at http://www.devcurry.com/2011/02/call-javascript-function-from-aspnet.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM