• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 581
  • Last Modified:

Retrieving QueryString Information

This is not an exam or homework

You are in charge of receiving QueryString information for the page "MyPage.aspx", (e.g. "MyPage.aspx?UserName=Bob"). Which of the following reads the information from the QueryString and assigns the value to a label called "Label1" that has been added to the page?

1. Label1.Text = Server.QueryString("UserName")
 
2. Label1.Text = Page.QueryString("UserName")
 
3. Label1.Text = HttpContext.QueryString("UserName")

4. Label1.Text = Request.QueryString("UserName")
0
cybernation989
Asked:
cybernation989
  • 2
  • 2
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>This is not an exam or homework
I am sorry, but this looks too much like it, or like exam preparation.

you should be able to answer that by trying out, if necessary...
0
 
Chandan_GowdaCommented:
the below one wil work
Label1.Text = Request.QueryString("UserName").ToString()
0
 
cybernation989Author Commented:
At first I was going to say 2 but after checking out http://www.pcreview.co.uk/forums/thread-1273353.php I would have to say 4 Since I am new to asp.net please let me know what you think
0
 
Chandan_GowdaCommented:
befor assigning the query string to the label it should be converted to a string
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the suggested answer #2 is "misleading".
the "full" code would be Page.Request.QueryString("UserName")...
but "page" is implicitely usable, so answer #4 is correct.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now