How to conditionally display content based on a session variable
Posted on 2009-05-13
One thing I did a lot of in Classic ASP involved showing page elements conditionally based on a session varriable I set. For instances, if the value of the session variable was "general" the user would get a little big of content and a couple of controls. If the value was "advanced" they would get MORE content and additional controls. Keep in mind this is all on the same page.
I would like to know generally how this is done in ASP.NET.
Again, I'd like to show folks a minimal version of the page, and show logged-in folks
a lot more.
Back in the day of Classic ASP I just check the value of my session variable and did an If... EndIf
If session("type") = "General" then
<p> You have the ability to update this page. Congrats!</p>
<!-- Show them the UPDATE button -->
But everything in ASP.NET is done via the code behind and I have no idea how to inject this sort of stuff from the code behind to the aspx page at the EXACT location I need the code to appear.
Can someone provide a best pratice example on how do do this?