Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Header/Footer by Inheritance?

Header/Footer by Inheritance?

Scheduled Pinned Locked Moved Web Development
questioncsharpasp-netsecurityoop
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrGlover
    wrote on last edited by
    #1

    What is my question? Hmm... Is there a clever .Net way to achieve what we used to do with includes with regard to headers and footers? In ASP you might do something like this .... <%Option Explicit%> <% Response.Write "HelloWorld" %> This is all fine and dandy, unless you want to actually do something dynamic in your header or footer (not out of the question) and pass through variables and such. For example, I often draw the side naviagtion in the header include and pass through the security level of the user (which alters the available menu options) so I usually do it like so... <%Option Explicit%> <% DrawHeader iLoginSecurityLevel Response.Write "HelloWorld" DrawFooter iLoginSecurityLevel %> Ok, so now the guts of my question with that in mind would be, is there a nice way to do this via perhaps the code-behind architecture and inheritance in ASP.Net? I am thinking that perhaps you'd have your own page which would inherit from Page and would implement a method to draw the header and footer on every page. If so, at what stage would I be writing the header and footer? Is there Page events that I could respond to before and after the .aspx stuff is written? Just wondering if anyone has taken this approach really and whether it worked out well. Ta in advance JBoy Talk is cheap because supply exceeds demand

    N 1 Reply Last reply
    0
    • M MrGlover

      What is my question? Hmm... Is there a clever .Net way to achieve what we used to do with includes with regard to headers and footers? In ASP you might do something like this .... <%Option Explicit%> <% Response.Write "HelloWorld" %> This is all fine and dandy, unless you want to actually do something dynamic in your header or footer (not out of the question) and pass through variables and such. For example, I often draw the side naviagtion in the header include and pass through the security level of the user (which alters the available menu options) so I usually do it like so... <%Option Explicit%> <% DrawHeader iLoginSecurityLevel Response.Write "HelloWorld" DrawFooter iLoginSecurityLevel %> Ok, so now the guts of my question with that in mind would be, is there a nice way to do this via perhaps the code-behind architecture and inheritance in ASP.Net? I am thinking that perhaps you'd have your own page which would inherit from Page and would implement a method to draw the header and footer on every page. If so, at what stage would I be writing the header and footer? Is there Page events that I could respond to before and after the .aspx stuff is written? Just wondering if anyone has taken this approach really and whether it worked out well. Ta in advance JBoy Talk is cheap because supply exceeds demand

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      You can actually still use the #Include if you would like even with .aspx pages, however to answer you question there is a .NET way of handling this. This is through the process of what Microsoft calls User Controls (file type .ascx). I have included a link below to a MSDN page that shows how to convert from the older style to the new user controls. I hope this answers your question. Converting a Web Forms Page to a User Control [New Window] Nick Parker

      M 1 Reply Last reply
      0
      • N Nick Parker

        You can actually still use the #Include if you would like even with .aspx pages, however to answer you question there is a .NET way of handling this. This is through the process of what Microsoft calls User Controls (file type .ascx). I have included a link below to a MSDN page that shows how to convert from the older style to the new user controls. I hope this answers your question. Converting a Web Forms Page to a User Control [New Window] Nick Parker

        M Offline
        M Offline
        MrGlover
        wrote on last edited by
        #3

        User controls ignore and

        tags, so it would not be possible to have a Header user control that defines say the following ... Northwind

        JBoy :confused:

        N 1 Reply Last reply
        0
        • M MrGlover

          User controls ignore and

          tags, so it would not be possible to have a Header user control that defines say the following ... Northwind

          JBoy :confused:

          N Offline
          N Offline
          Nick Parker
          wrote on last edited by
          #4

          True, I guess that's why they still allow the #include. :) Nick Parker

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups