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

adding variable to HTTP query string from code

Status
Not open for further replies.

dstepans

Programmer
Jun 3, 2003
39
0
0
US
Hello,

is it possible to add a variable to the HTTP query string?
For examle the requested URL was but in the page.aspx I have a control that queries the request.querystring("ID"), so what I need is to somehow in the code add an ID variable and set it to lets say 5, so request.querystring("ID") would return 5.

Thanks,
Denis
 
Hi!
You could add the desired querystring from the refferer page. I.e. on page1.aspx you can have a link like this:
Code:
<asp:HyperLink id="lnk" runat="server" NavigateUrl="[URL unfurl="true"]http://www.something.com?ID=5"/>[/URL]
or a button that has its onClick event like this:
Code:
Response.Redirect("[URL unfurl="true"]http://www.something.com?ID=5")[/URL]

I hope this is what you wanted!

[morning]
 
Hi,
thanks for your response.
Not what I wanted though.

What I would like to do is to exactly the opposite, I would like to avoid placing variable in the referred URLs. The url will look like or but in page5.aspx.vb file I need to somehow add Cat=5 to the querry string.

Thanks for any help guys.
Denis
 
I think you're referring to data persistence. There are quite a few methods. You could look into hidden form elements, cookies, session variables, temporary database tables, XML/Text Documents, Page properties ... You can then retreive this data and then append it to the URL as a querystring variable.

HTH,

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top