473,888 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.redire ct, 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 14975
The Request.QuerySt ring 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.Redire ct 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.ne t> wrote in message
news:#b******** ******@TK2MSFTN GP10.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.redire ct, 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******** ******@TK2MSFTN GP12.phx.gbl...
The Request.QuerySt ring 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.Redire ct 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.ne t> wrote in message
news:#b******** ******@TK2MSFTN GP10.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.redire ct, 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
1395
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 On my news.aspx page I have some usercontrols (header.ascx, leftside.ascx, rightside.ascx, footer.ascx and newsmiddle.ascx). I want to put the news from the id in the querystring in the newsmiddle.ascx component.
1
1328
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. ?page=2). The paging works as designed but when I click the submit button to view/refresh the list, the querystring with the last page stays in the url. How can I remove the "?page=x" from the end after submitting? Thanks
2
6065
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. Bookmarks don't actually work on our site, so they serve no purpose, and I feel it would be clean if the url was just http://www.mysite.com. Any help would be greatly appreciated. Gala Grant
1
1138
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 city and clicked the btnfindrestaruants button, it should redirect to storelist.aspx page by using querystrings and list all the restaurants belongs to the selected State and city. However, after user selected the state and city, and clicked the
3
1221
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 the querystring and just leave the url (mypage.aspx?id=1 -> mypage.aspx)
5
2786
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. I would like to have a different user control that gets loaded as a sub-header for each category (ie, tee shirts, shoes, backpacks, etc.) The category user controls include images and links to refined searches specific to each category. So...
2
1439
by: ABC | last post by:
How to remove the queststring of a page?
5
1517
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 called the method Properties_Set() and that didn't help. Can anyone provide a solution? Please see code below. Thanks in advance.
2
11917
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 tried Request.QueryString.Clear(); and the error was the variable is readonly.
0
9961
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5819
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.