Web Page Organization

This is a discussion on Web Page Organization within the C# Programming forums, part of the General Programming Boards category; I have done a lot of reading on ASP.NET with VB and C#. Mostly, I have been reading ASP.NET unleashed. ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    18

    Web Page Organization

    I have done a lot of reading on ASP.NET with VB and C#. Mostly, I have been reading ASP.NET unleashed. I am not clear on this general concept:

    Can you convert an entire project and use it as an include in a web page? Basically, can you open up VS.NET, create a new project, and start coding? Then, in a web page that already exists, use that project in it.

    What I am trying to do is seperate my page into sections. For example, I have a poll. I can get the poll to work using a code behind file. Im wondering if I can create a project with HTML and code behind, then include the enitre project into another web page. This way, if I had 5 web pages, all I would have to do is include the poll 5 times.

    If the above isn't clear, here is a look at my general set up:

    Index.aspx
    - include header.aspx
    - include body.aspx
    - include rightnavbar.aspx
    - include footer.aspx
    End Index

    In rightnavbar, there is a poll. Inside the file rightnavbar.aspx, i would like to be able to include a poll "module". The problem with using a bunch of different code behinds is that every page is inside of index.aspx, and index can only have one code behind - this makes for to much code in one file.

    So, any advice to point me in the right direction is appreciated. How would you organize a project like this?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    I don't do any web based coding and no ASP, but normally, your setup would consist of different frames with different sources I think. There should be no need to put all your modules into one source file.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    To include non-asp.net scripted files, you can just use:
    Code:
    <% Response.WriteFile("file.html"); %>
    Unfortunately, ASP.NET can't include other aspx files in each other. However, you can create user controls (like web components) that you can include in your files. So you can have a top user control, a bottom user control and your content in the middle. These user controls can output the neccesary html.

    You can do this with a function, as well. Just make a module (or static functions) that output the appropiate html.

  4. #4
    Registered User
    Join Date
    Dec 2003
    Posts
    18

    Includes

    Thanks for the replies. If anyone was curious, I ended up creating one project, and having multiple namespaces. One namespace, for example, is poll. My main codebehind page will call a function from Poll, and send it the selected index. I did this for user login, news, message board, etc.

    Speedy, you mentioned you can't include aspx files inside one another. In my page, I used the following:

    <!--#include file="Design/Header.aspx"-->

    So far it works. Is this bad practice?

    Thanks again,

    Khelder

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Sure you can include them but any server-side ASP.NET code in it will not execute (as far as I know). Client-side javascript will though.

    I think what you are using are server-side includes done on the server application. I recommend you use the Response.WriteFile() method instead if you are including other HTML files.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to capture POST method from Web Page
    By nice_guy_mel in forum Networking/Device Communication
    Replies: 8
    Last Post: 04-01-2005, 05:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21