Solved

Retrieving QueryString Information

Posted on 2007-11-28
5
573 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Disable and re-enable a dynamic System.Timers.Timer 6 40
ASP.NET reading ATOM 2 51
asp.net mvc return json 2 56
Error in JQuery 5 39
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now