473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Add, remove or change QueryString at runtime

Hi!

I need to be able to change, add or remove items in the QueryString.

Let say I have the following scenario:

Page_1.aspx display a dropdown list. This list is post-back enabled. It can
also change the selected item by requesting the querystring ?color=red.

If I browse to the page via the link
http://localhost/page_1.aspx?color=green, the background-color will be -
green. If I now select another color from the dropdown, let say red, I want
to change the background-color to red and ALSO set the querystring 'color'
to the value "red". I thought I could somehow manipulate the ViewState with
the following line:

ViewState.Add("color", "red")

However, this line dows not change the QueryString. i thought about
response.redirect, but that will post the page twice, right?

So, does anybody have any idea how to do this? Can I manipulate the
QueryString at run-time?

Thanks in advance,
Fredrik
Nov 18 '05 #1
2 14955
The Request.QueryString property is read-only, as are all other items
received from the client's Request. After all, it IS the client's request.
If you ordered a steak in a restaurant, and they brought you fish, they
wouldn't be changing your order; they would be making up their own. It's the
same principle. If you want to change the QueryString, you have to create
your own Request, which is what Response.Redirect does. It sends a response
to the client telling it to send a new Request, according to the parameters
sent in the Response.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Fredrik Rodin" <ro***@dacsa.net> wrote in message
news:#b**************@TK2MSFTNGP10.phx.gbl...
Hi!

I need to be able to change, add or remove items in the QueryString.

Let say I have the following scenario:

Page_1.aspx display a dropdown list. This list is post-back enabled. It can also change the selected item by requesting the querystring ?color=red.

If I browse to the page via the link
http://localhost/page_1.aspx?color=green, the background-color will be -
green. If I now select another color from the dropdown, let say red, I want to change the background-color to red and ALSO set the querystring 'color'
to the value "red". I thought I could somehow manipulate the ViewState with the following line:

ViewState.Add("color", "red")

However, this line dows not change the QueryString. i thought about
response.redirect, but that will post the page twice, right?

So, does anybody have any idea how to do this? Can I manipulate the
QueryString at run-time?

Thanks in advance,
Fredrik

Nov 18 '05 #2
Kevin,

Thanks for your reply.

That's was basically a "- Forget it!";-)

/Fred

"Kevin Spencer" <ke***@takempis.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl...
The Request.QueryString property is read-only, as are all other items
received from the client's Request. After all, it IS the client's request.
If you ordered a steak in a restaurant, and they brought you fish, they
wouldn't be changing your order; they would be making up their own. It's the same principle. If you want to change the QueryString, you have to create
your own Request, which is what Response.Redirect does. It sends a response to the client telling it to send a new Request, according to the parameters sent in the Response.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Fredrik Rodin" <ro***@dacsa.net> wrote in message
news:#b**************@TK2MSFTNGP10.phx.gbl...
Hi!

I need to be able to change, add or remove items in the QueryString.

Let say I have the following scenario:

Page_1.aspx display a dropdown list. This list is post-back enabled. It

can
also change the selected item by requesting the querystring ?color=red.

If I browse to the page via the link
http://localhost/page_1.aspx?color=green, the background-color will be -
green. If I now select another color from the dropdown, let say red, I

want
to change the background-color to red and ALSO set the querystring 'color' to the value "red". I thought I could somehow manipulate the ViewState

with
the following line:

ViewState.Add("color", "red")

However, this line dows not change the QueryString. i thought about
response.redirect, but that will post the page twice, right?

So, does anybody have any idea how to do this? Can I manipulate the
QueryString at run-time?

Thanks in advance,
Fredrik


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bernie V | last post by:
Hey group ! I have a page where I have a newssection. Each line is a link. Is it possible to use a page news.aspx where I work with a querystring to refer to the page ? example: news.aspx?id=3...
1
by: Amy Snyder | last post by:
I think I have my brain still stuck in the classic ASP model and can't seem to solve this easy problem. I have a datalist with paging. I have my page numbers appended with the page (i.e....
2
by: Gala Grant | last post by:
Hello, I am trying to find if there is a setting somewhere that I can change that will remove the "ReturnUrl=blah.aspx" from the url when someone tries to access a page without being logged in. ...
1
by: JenHu | last post by:
In my restaurant.aspx, I have a 2 dropdownlists (ddlState, ddlCity) and a button (btnFindRestaurants). The 2 dropdownlist has the first item as "--Choose--" After user selected a state and a...
3
by: Mortar | last post by:
i would like to know if there is a way to change the address in the browser, without actually changing to it or submitting. i.e. after a page loads that has a querystring, i want to get rid of...
5
by: footballhead | last post by:
I have a site that has MANY different clothing categories. I have a page set up for displaying the products (productsearch.aspx) when a user clicks one of the category links on the navigation menu....
2
by: ABC | last post by:
How to remove the queststring of a page?
5
by: ryanwpenfold | last post by:
Hi, The variable _intBlogID changes from -1 to 0 when the Mode_Get method is called. I don't understand why this happens. I included default property values, and that didn't help. I wrote and...
2
by: omlac | last post by:
Hi all How do i delete/remove a Querystring variable. say Request.QueryString); i have tried this Request.QueryString.Remove(0) but it didnt remove it nor did it give an error message. I also...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.