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. ASP.NET
  4. What's the equivalent to #include

What's the equivalent to #include

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netwinformscomquestion
6 Posts 3 Posters 32 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.
  • F Offline
    F Offline
    Frank Liao
    wrote on last edited by
    #1

    What's the equivalent to using #include files in ASP.NET?

    The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc. Right now, my guess is that you can only use user controls, but I don't this method would allow me to enclose the main page in a and tag.:~ Frank http://www.frankliao.com

    P 1 Reply Last reply
    0
    • F Frank Liao

      What's the equivalent to using #include files in ASP.NET?

      The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc. Right now, my guess is that you can only use user controls, but I don't this method would allow me to enclose the main page in a and tag.:~ Frank http://www.frankliao.com

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      Frank Liao wrote: The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. About the only reason I see for using include files anymore is if you are porting a lot of ASP over to ASP.NET. Other than that, probably best to avoid.

      Paul Watson
      Bluegrass
      Cape Town, South Africa

      Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson

      L 1 Reply Last reply
      0
      • P Paul Watson

        Frank Liao wrote: The reason I want to use include files is because I want to maintain a template on all .aspx pages so that if my boss wants to change the look of the company page, I wouldn't need to change every single page. I would have files like _top.inc and _bottom.inc Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. About the only reason I see for using include files anymore is if you are porting a lot of ASP over to ASP.NET. Other than that, probably best to avoid.

        Paul Watson
        Bluegrass
        Cape Town, South Africa

        Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Paul Watson wrote: Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. Templating perhaps, inheritance not, I struggled with that for days and can confirm (by looking at the output html) that there are some "serious" flaws in that approach. See a post of mine about a week back of how I think you should do it. http://www.codeproject.com/script/comments/forums.asp?msg=315584&forumid=12076&mode=all&userid=38829#xx315584xx[^]. I can honestly say my way is a much better approach and "more" inline with the ASP.NET way. Cheers :) PS: Happy B-day for yesterday ;) "There are no stupid question's, just stupid people."

        P 1 Reply Last reply
        0
        • L leppie

          Paul Watson wrote: Yes you can use User Controls/Custom Controls/Etc. Controls (even with the TD problem you mentioned) but it is probably better to use proper page inheritance, templating in ASP.NET. Templating perhaps, inheritance not, I struggled with that for days and can confirm (by looking at the output html) that there are some "serious" flaws in that approach. See a post of mine about a week back of how I think you should do it. http://www.codeproject.com/script/comments/forums.asp?msg=315584&forumid=12076&mode=all&userid=38829#xx315584xx[^]. I can honestly say my way is a much better approach and "more" inline with the ASP.NET way. Cheers :) PS: Happy B-day for yesterday ;) "There are no stupid question's, just stupid people."

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          leppie wrote: that there are some "serious" flaws in that approach. How so? I had a look at your post below, but what is different with your approach to the other articles approach?

          Paul Watson
          Bluegrass
          Cape Town, South Africa

          Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson

          L 1 Reply Last reply
          0
          • P Paul Watson

            leppie wrote: that there are some "serious" flaws in that approach. How so? I had a look at your post below, but what is different with your approach to the other articles approach?

            Paul Watson
            Bluegrass
            Cape Town, South Africa

            Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            By overriding Render() in a page class, you basically remove the "Page" functionality and have to do all the rendering yourself. Also base.Render() should NOT be called as in the article, but like I said Render() is a core function of the Page class and you need that. I you paste his example in a file, and run it you will see that the outputted HTML is wrong, like a page within a page, because of the base.Render() that's being called. Now you can replace base.Render() with RenderChildren() (i think the output will be better), but you have lost 80% of the Page classes functionality by this point, defeating the point of inheritance. My way, I programmtically add controls at page initialization to achieve the inherited effect and keep page functionality. You still however lose designer support. Cheers :) "There are no stupid question's, just stupid people."

            P 1 Reply Last reply
            0
            • L leppie

              By overriding Render() in a page class, you basically remove the "Page" functionality and have to do all the rendering yourself. Also base.Render() should NOT be called as in the article, but like I said Render() is a core function of the Page class and you need that. I you paste his example in a file, and run it you will see that the outputted HTML is wrong, like a page within a page, because of the base.Render() that's being called. Now you can replace base.Render() with RenderChildren() (i think the output will be better), but you have lost 80% of the Page classes functionality by this point, defeating the point of inheritance. My way, I programmtically add controls at page initialization to achieve the inherited effect and keep page functionality. You still however lose designer support. Cheers :) "There are no stupid question's, just stupid people."

              P Offline
              P Offline
              Paul Watson
              wrote on last edited by
              #6

              leppie wrote: My way, I programmtically add controls at page initialization to achieve the inherited effect and keep page functionality. You still however lose designer support. OIC, I thought you were saying the whole ASP.NET inheritance, override thing was flawed. Had me worried for a bit. Overriding the render event is not always needed, but in some cases you have to.

              Paul Watson
              Bluegrass
              Cape Town, South Africa

              Ray Cassick wrote: Well I am not female, not gay and I am not Paul Watson

              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