Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Single ASP/ASP.NET File For All Includes?

    HI, first off I really don't know anything about ASP or .NET, I mainly specialise with PHP, however I'm building a site on a server that onyl supports ASP and ASP.NET. What I want to do is simulate the same thing I usually do with PHP, whereby instead of having include lines in each page for the site to display headers, footers, and side menus etc, I have one single file, in the past cases this was just an index.php with the following code:

    Code:
    <?php
    
    if (!empty($_GET['id'])) {
    	$id = $_GET['id'];
    	$inklood = 'content/' . $id . '.php';
    } else {
    	$id = 'home';
    	$inklood = 'content/main.php';
    }
    if (!file_exists ($inklood)) {
    	$bad_path = 'index.php?id=' . $id;
    	@include ('errors/404.html');
    } else {
    	@include ('header.php');
    	@include ('right.php');
    	@include ('left.php');
    	@include ($inklood);
    	@include ('footer.php');
    }
    
    ?>
    So basically you'd always have that file display the header, side bars, then the specific page contents using a query line like index.php?id=yourpage followed by the footer after that. I much prefer this method rather than having the same includes in every page, is it possible to replicate this method in ASP or ASP.NET? Any help would be great.

    (Btw incase you're wondering why in that list the right bar is included before the left bar it's because this is done in XHTML using negative margins and floats so I have the code for all menus before the content so my skip nav link jumps all menu links as im building a fully accessible site.)

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    None of them seem to be what I'm looking for and the ones that are just don't seem to work.

    I basically want it to function the same way as the PHP code i posted does, whereby you'd specify the "dynamically included" file from the url like index.asp?id=whateverpage and also in the event that no file is specified in the url, like the page is just linked to say index.asp a default "included" file will display. Prefarrably I'd also like this to be a case where you can specify the directory where these files reside, like in the PHP code they were specified to be in the directory "content". Returning an error page if the file doesn't exist isn't really needed though.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    asp.net:

    Look into usercontrols for you header,footer, menu ect. You can also use something called Masterpages for templating in .net 1.1. When researching Masterpages ignore the 2.0 stuff since it is currently unavailable.


    http://aspnet.4guysfromrolla.com/articles/040704-1.aspx will get you started (Look into the Paul Wilson version at the bottom of the page).
    does this sig match?

  • #5
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's alright i got it working now. Thanks for the help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •