Last post Feb 15, 2012 03:51 PM by dezinnia
Feb 15, 2012 03:19 PM|dezinnia|LINK
Just getting my feet wet in this...
In Classic ASP, if I wanted to display certain static content based on a querystring, it's easy...
Like, I might have a list of people on a firm's "people" page, and the links just point to the same page, but differentiated by querystring value...
And then I would display the content like this:
<% if request.querystring("person") = "bob" then%>
Bob is a great guy
<% elseif request.querystring("person") = "carol" then%>
Carol is a great gal....etc...
and then maybe end with an "else" that just displays the default info for the whole firm. (if they don't chose a valid querystring value.)
So, HOW THE HECK WOULD YOU DO SOMETHING LIKE THIS IN ASP.NET? Is it even possible?
I'm not grabbing the content out of a database; it just lives on the page. If I have to create individual pages for each of the four people, well, then fine, but that seems not so efficient.
I'm using C#...Does the "check" for querystring have to happen in the codebehind? So, if you check for it there, how do you tell the aspx page what content to display based on the querystring?
Feb 15, 2012 03:23 PM|MetalAsp.Net|LINK
Feb 15, 2012 03:24 PM|dezinnia|LINK
if you could give me a simple example of what would go on the codebehind page, and then on the aspx page, I would be forever in your debt! ;)
Feb 15, 2012 03:29 PM|OnoSendai|LINK
Did you tried using the same content on an aspx page? they would work in exactly the same fashion. =)
Request.QueryString also exists on ASP.NET, altho with slightly different/additional features.
Now, to obtain a similar behaviour on your ASP.NET application, i'd suggest this:
Feb 15, 2012 03:35 PM|MetalAsp.Net|LINK
Feb 15, 2012 03:51 PM|dezinnia|LINK
OK, I did this on the aspx page:
<asp:Panel ID="bobpanel" runat="server" Visible="false">
Blah Blah Content for Bob
And then on the codebehind page I did this:
string p = Request.QueryString["p"];
if (p == "1")
bobpanel.Visible = true;