Run code in included aspx file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cbellew
    New Member
    • Sep 2007
    • 26

    Run code in included aspx file

    Hi there,

    I wonder if anyone can help me with my problem...

    I have a website in which a "header.asp x" is included the top of all the standard web pages. Inside this header file i would like to include code to manipulate what is shown from inside this "header.asp x" file. Is this possible?

    I would like to run the following each time a page is called. The "headermenu " is a div in the "header.asp x" file I would like to remove if the user is not "logged in".
    Code:
    if (Session["logged"] != true)
    {
        headermenu.OuterHtml = "";
    }
    Where should the code go or am i doing it wrong?

    Thank you enormously,

    Chris
    Last edited by Frinavale; Apr 21 '09, 01:28 PM. Reason: Added code tags. Please post code in [code] [/code] tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Instead of having a Header.aspx page, consider using MasterPages.

    MasterPages are compiled along with the a content page and to create a whole page. They're pretty much like a template that is applied to every page in your web application. You can add code in the MasterPage to determine what to display depending on whether or not the user's logged in.

    Comment

    • cbellew
      New Member
      • Sep 2007
      • 26

      #3
      OK, i'll take a look - have not heard of them before but sounds like the answer.

      Thanks

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        The MSDN Library is a great resource for these types of things. For instance you may find this article interesting.

        Comment

        • cbellew
          New Member
          • Sep 2007
          • 26

          #5
          ah, thanks again.

          Chris

          Comment

          Working...