Solved

Retrieving QueryString Information

Posted on 2007-11-28
5
574 Views
Last Modified: 2011-09-20
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
Comment
Question by:cybernation989
  • 2
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20363919
>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
 
LVL 7

Accepted Solution

by:
Chandan_Gowda earned 250 total points
ID: 20363968
the below one wil work
Label1.Text = Request.QueryString("UserName").ToString()
0
 

Author Comment

by:cybernation989
ID: 20364014
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
 
LVL 7

Expert Comment

by:Chandan_Gowda
ID: 20364025
befor assigning the query string to the label it should be converted to a string
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 20364056
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question