SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile How do I triage REQUEST variables in ASP.NET?

    My website uses one page and pulls in the content for that page based on GET (Request) variables appended to the url.

    So

    mysite.com?page=content
    mysite.com?page=aboutus

    etc. etc. pretty standard stuff.

    I built it in PHP but I'm switching over to C# .NET as a learning experience for myself.

    In PHP I just simply said:



    PHP Code:
     $in $_GET['page']; 
         if(
    strlen($in) > 0) {
         
         include_once(
    "include-".$in.".php");
         }else{
        include_once(
    "include-index.php");
        
        } 

    Now , I've figured out that to include pages in Asp.net, you can do

    <!-- #include file= "pagetoinclude.aspx" -->

    And I've also seen that with code behind, there's a built in C# method VC builds in for you :

    Code Csharp:
    protected void Page_load(object sender, Event Args e)

    but I'm struggling with how to make run time decisions in the page itself. if

    String name = Request["aboutus"] ;

    then how do I make ASP plop the include file in a certain part of the page? I hope I'm making sense.


    Any help would be appreciated.

    I know this a pretty standard procedure so please excuse the novice.

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Hmm. I'd have to know more about your plan to make a suggestion but it's probably best to either stick with PHP or scrap it and start fresh with a more modern plan.

  3. #3
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if I'm doing it in ASP.NET, what is a more modern plan ?

    I see most websites do something like this...... one home page whose content changes based on string variables from the URL.

    Unless you mean pulling ALL content from a database..... I could do that, but it's a LOT easier to make include pages so I can design them visually at will and pull them in.

    Let me know and thanks for the initial feedback.

    I'm open to ANYTHING though. I will shape my plan based on the feedback I get here. It's a common procedure so what's the modern way to do this.

  4. #4
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shem View Post
    ... Unless you mean pulling ALL content from a database..... I could do that, but it's a LOT easier to make include pages so I can design them visually at will and pull them in. ...
    I can't fathom how that is easier. The database can contain anything that the include files contain so I'm not seeing where you're coming from.

    My suggestion would be a MasterPage and pulling the content from the database.

  5. #5
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well , again, maybe the way I'm doing this is old, but it's very easy for me to design a page full of CSS, images, flash content, etc. in Dreamweaver and then save that page as a "include" page . The visual part of actually seeing my page , rather than just dumping the code for that page in a database, is what I'm referring to. I can open up the page in Dreamweaver (or Visual Studio in this case) and tweak things without having to dig into a database.

    That's what I mean. How do you do it? I really am open to learning new ways, I just need to be pointed in the right direction.

  6. #6
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm already kind of using the Master Page Idea. MOST of the rich content is in my Master page. It's just that the individual pages have a lot of rich content also in them.


    LET'S SAY I just use the Master Page concept and pull data in from the database. I still need to do the "triage" based on a string in the url . How do I load different database stuff based on these unique Request variables in each respective url ?

    In other words, can you point me to how this is done in .NET ?

  7. #7
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Oh, man. I just typed out a huge explanation and then closed the page before posting. CRUD!

    I'm going to go succinct this time.

    In your MasterPage create a menu using an unordered list that contains the PageName anchored to a Stub for each page contained in the database. When one of the menu items is clicked it will populate the Content and PageTitle by checking the Stub in the URL against the Stub in the database.

    In my CMS for the default page I make a URL without the Stub show either the page titled "Home" or the page with the lowest ID or earliest CreationDate. I no longer use a Query String as I've switched to ASP.NET MVC and use Routing as it makes for nicer URLs.

    I made the CMS for people that don't understand HTML so I used Tiny-MCE to input the content. I liked it so much that I use it on my own sites now, too.

  8. #8
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok THAT is VERY very helpful and specific. That gives me the direction I'm looking for .and some projects to tackle to get where I need to be.

    Really appreciate the tip! Very useful.

  9. #9
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I'd do it the same way in PHP, too.


Bookmarks

Posting Permissions

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