Request.QueryString execute

A

Alex Schatten

Hi

in ASP i used following code for reading the Request.QueryString and setting my variables

for each key in Request.QueryString

x= key & "=" & chr(34) & Request.QueryString(key)& chr(34)

execute(x)

next

Can i realize somthing similiar in aspnet?



Regards, Alex
 
J

Juan T. Llibre

You can use the ParseQuerystring method of HttpUtility.

See this sample code :
http://msdn2.microsoft.com/en-us/library/ms150046.aspx

Basically :

Dim qscoll As NameValueCollection = HttpUtility.ParseQueryString(querystring)

Dim sb As New StringBuilder("<br>")
For Each s As String In qscoll.AllKeys
sb.Append(s & " - " & qscoll(s) & "<br>")
Next s
ParseOutput.Text = sb.ToString() 'if you're displaying to a Label

If you are sure that the URL will always have a querystring collection, you can
skip the check for the existence ( and adding of ) querystring value pairs in the example.





Hi

in ASP i used following code for reading the Request.QueryString and setting my variables

for each key in Request.QueryString

x= key & "=" & chr(34) & Request.QueryString(key)& chr(34)

execute(x)

next

Can i realize somthing similiar in aspnet?



Regards, Alex
 
A

Alex Schatten

Thank you for your answer.
But do i have then the value of the querystring in a variable and can use them?

In ASP when i have a string like index.asp?x=1&y=2&z=3
my example
for each key in Request.QueryString
x= key & "=" & chr(34) & Request.QueryString(key)& chr(34)
execute(x)
next
returns the variabele
x with the value 1, y with the value 2 etc.

How does this work in your example?

Regards, Alex
 
J

Juan T. Llibre

The content of the string is in sb.ToString()

Instead of filling the Label control with ParseOutput.Text = sb.ToString()
you can dim another variable and fill it with sb.ToString()

Dim x As String = sb.ToString()

' do whatever you want with the variable x.

I set up an example for you :

http://asp.net.do/test/parsequerystring2.aspx?x=1&y=2&z=3
( identical query string per *your* example... )

Check it out...




Thank you for your answer.
But do i have then the value of the querystring in a variable and can use them?

In ASP when i have a string like index.asp?x=1&y=2&z=3
my example
for each key in Request.QueryString
x= key & "=" & chr(34) & Request.QueryString(key)& chr(34)
execute(x)
next
returns the variabele
x with the value 1, y with the value 2 etc.

How does this work in your example?

Regards, Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top