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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query String encoding 1

Status
Not open for further replies.

Zarcom

Programmer
May 7, 2002
1,275
CA
Hey guys I had an bug where my query string data wasn't coming through when I passed odd characters through the query string. In my specific case I was trying to pass "&" through. Since this is the delimiter for the query string it only sees part of the data on the other side.

ex
someaddress?Manu=O&K

The other side sees Manu=O

I remembered seeing a method that took care of that for me, so after a bit of searching I came across HttpUtility.UrlEncode("String") My address line now looks like this

"someaddress?Manu=" + HttpUtility.UrlEncode("0&K");

Works just dandy. Hope you find it usefull

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Or just say ta-heck with querystring!

Viewstate, viewstate, viewstate!

(hey...I bet Steve Ballmer could chant that and some hacker could make a follow up to that Developer music video!)

;)

D

ps. I'm working with a horrible system that relies on querystring right now. Its still a great way to pass parameters, I'm just bitter right now. ;)
 
Is viewstate ok to use as a replacement for the querystring for passing values? Does it require cookies on the user's machine like server var's?
 
It depends on what you mean by "passing"

If you're going page to page, viewstate won't help because only one page will have its own viewstate (its not like Session where its global accross all pages).

However, if you had a situation where your page was posting back to itself, and it had to tell itself a value, or hold a value for a prolonged period of time, I'd personally rather store it in viewstate than in query string (less to show the user).

It all really depends on the architecture of your site
i.e. I usually have one page that performs the bulk of functionality, but dynamically shows/hides things depending on parameters. So I don't jump to too many pages in my apps. Viewstate is preffered in that scenario than query string. In other apps it might be different.

hope that cleared it up bigfoot, sorry if I caused confusion

D

 
I do agree with Jack if your staying on the same page don't use a querystring the viewstate is a better option, but to pass variables from one page to another I find that a querystring is the best bet most of the time.

I say "most" cause you don't want to go sending passwords or sensitive data through the query string.

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
I just found another way. Please read my post called Helo with passing values.
 
Should have been Help with passing values. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top