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.


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:

 $in = $_GET['page']; 
	 if(strlen($in) > 0) {

Now , I’ve figured out that to include pages in, 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 :

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.

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.

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.

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.

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.

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 ?

Oh, man. I just typed out a huge explanation and then closed the page before posting. :frowning: 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.

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.

I’d do it the same way in PHP, too. :wink: