Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Completely new to this, sub procedures

Status
Not open for further replies.

mainmast

Programmer
Jun 26, 2003
176
US
Hi all,

I am currently working through a book teaching me about ASP.NET. I have taught myself ASP pretty well over the past several years, but I am having trouble with ASP.NET.

I need to be able to show different content according to the querystring. I already know how to grab the information in the querystring and put it into a string variable, but I need to be able to call different content based on that information. In ASP I would use sub procedures, but I am not for sure about ASP.NET.

How would I do the above?
 
One of the cool things about .NET is that it frees you up to take a more object-oriented approach.

The easy way to do what you want to do is set properties based on the QueryString value (e.g. myTextBox.Text = queryStringVal) then let ASP.NET do the work of rendering the control for you, but if you need something more robust like dynamic control generation, you can also harness design patterns like factories/ builders.
 
Thanks for your response BoulderBum.

I'm basically trying to show two different web forms according to the querystring, which will include more ASP.NET and HTML coding. How would I do that?

Thanks!
 
If by web forms you mean you want to display different pages then you can do something like:
Code:
If Request.Querystring("myVariable") = "Y" Then
    Response.Redirect("Page1.aspx")
Else
    Response.Redirect("Page2.aspx")
End If


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
You can also leave the user on the same page and dynamically load "User Controls" so you don't have to redirect, but it's a little more tricky.


Basically the way it works is you have two User Controls which are essentially chunks of pages you can program against, then you can develop and maintain each separately with full designer support. When the page loads, you look at the QueryString and load one or the other control (or whichever else you want).

If you want the page loader/redirector to be flexible and extensible, you can also utilize an abstract factory pattern:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top