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. General Programming
  3. .NET (Core and Framework)
  4. ASP.NET

ASP.NET

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpquestionasp-netdesignregex
6 Posts 3 Posters 26 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
    Matt W
    wrote on last edited by
    #1

    Hi folks, Lately I have been spending some time attempting to get my head around ASP.NET. One on the exercises I have set myself is to build a modest little website. But I have run into a few design problems that I hope some one can help me with. I have decided to have a standard header to each page. (Just like code project has the standard header at the top of this page.) In pure ASP I would have had these as a SSI (eg . In ASP.NET this still works but when I attempt to add make the header a bit smarter by making it a WebForm things get all confused. This happens because they are each seperate pages with seperate C# code behind them. Which means there is two <@ Page ...> directives. Which means it doesn't work! What is the proper design pattern/model to acheive this type of behaviour? I hope this makes sense to you all... Matt ------ Accept that some days you are the pigeon and some days the statue.

    J L 2 Replies Last reply
    0
    • M Matt W

      Hi folks, Lately I have been spending some time attempting to get my head around ASP.NET. One on the exercises I have set myself is to build a modest little website. But I have run into a few design problems that I hope some one can help me with. I have decided to have a standard header to each page. (Just like code project has the standard header at the top of this page.) In pure ASP I would have had these as a SSI (eg . In ASP.NET this still works but when I attempt to add make the header a bit smarter by making it a WebForm things get all confused. This happens because they are each seperate pages with seperate C# code behind them. Which means there is two <@ Page ...> directives. Which means it doesn't work! What is the proper design pattern/model to acheive this type of behaviour? I hope this makes sense to you all... Matt ------ Accept that some days you are the pigeon and some days the statue.

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      I think the ASP.NET way would be to create a new server control encapsulating the header. A lot more info on doing such a thing can be gleaned from the IBuySpy set of websites. HTH, James Sonork ID: 100.11138 - Hasaki

      M 1 Reply Last reply
      0
      • J James T Johnson

        I think the ASP.NET way would be to create a new server control encapsulating the header. A lot more info on doing such a thing can be gleaned from the IBuySpy set of websites. HTH, James Sonork ID: 100.11138 - Hasaki

        M Offline
        M Offline
        Matt W
        wrote on last edited by
        #3

        thanks for the tip. I am having a look at ibuyspy right now! Matt ------ Accept that some days you are the pigeon and some days the statue.

        L 1 Reply Last reply
        0
        • M Matt W

          thanks for the tip. I am having a look at ibuyspy right now! Matt ------ Accept that some days you are the pigeon and some days the statue.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          There are 2 choices, you could compile your own control into a dll, or you could make a UserControl file, with an ascx extension. Judging by the fact that you are making a header, i'm betting you want to make a UserControl, which is much like the old asp include file, except much much cooler. here's the msdn docs on UserControls, ( watch for wrapping ) http://msdn.microsoft.com/library/?url=/library/en-us/cpref/html/cpref\_start.asp?frame=true

          M 1 Reply Last reply
          0
          • L Lost User

            There are 2 choices, you could compile your own control into a dll, or you could make a UserControl file, with an ascx extension. Judging by the fact that you are making a header, i'm betting you want to make a UserControl, which is much like the old asp include file, except much much cooler. here's the msdn docs on UserControls, ( watch for wrapping ) http://msdn.microsoft.com/library/?url=/library/en-us/cpref/html/cpref\_start.asp?frame=true

            M Offline
            M Offline
            Matt W
            wrote on last edited by
            #5

            Thanks for the help. Much appreciated. I am experimenting with them at the moment. :) Matt ------ Accept that some days you are the pigeon and some days the statue.

            1 Reply Last reply
            0
            • M Matt W

              Hi folks, Lately I have been spending some time attempting to get my head around ASP.NET. One on the exercises I have set myself is to build a modest little website. But I have run into a few design problems that I hope some one can help me with. I have decided to have a standard header to each page. (Just like code project has the standard header at the top of this page.) In pure ASP I would have had these as a SSI (eg . In ASP.NET this still works but when I attempt to add make the header a bit smarter by making it a WebForm things get all confused. This happens because they are each seperate pages with seperate C# code behind them. Which means there is two <@ Page ...> directives. Which means it doesn't work! What is the proper design pattern/model to acheive this type of behaviour? I hope this makes sense to you all... Matt ------ Accept that some days you are the pigeon and some days the statue.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Matt, You can make that header two ways. 1.) make it a Web User Control and then on any page you want that headret you simply insert your header user control. You also could implement the Application BeginRequest event in the global.asax file. Like this and emit a header without having to explicitly add it to each page. Sub Application_BeginRequest(sender As Object, e As EventArgs) ' emit page header Context.Response.Write("" + ControlChars.Lf + _ "" + ControlChars.Lf + "


              " + _ ControlChars.Lf) End Sub Good Luck, Martin Garins

              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