473,320 Members | 1,953 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,320 software developers and data experts.

Clearing QueryString Name/Value pair from URL

Jon
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.aspx?id=foo">

When the page reloads, code in Page_Load then takes the appropriate
action based on finding the 'id' name/value pair in the URL
querystring. This works well.

However, I've noticed that all subsequent posts back to the page
retain the querystring. So if a user presses another button on the
form, .NET reposts this URL: mypage.aspx?id=foo (and my page_load
code is executed again).

What I'd like to do is remove the querystring ('?id=foo') from the URL
that .NET uses on all following post backs. I tried to do this
through some of the Request objects but had no luck (most were read
only).

Does anyone know how to modify the querystring or header stored by
..NET that's used for post back events?

~ Jon
Nov 18 '05 #1
3 12658
You could always Response.Redirect to the correct URL.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Jon" <to****@hotmail.com> wrote in message
news:e4**************************@posting.google.c om...
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.aspx?id=foo">

When the page reloads, code in Page_Load then takes the appropriate
action based on finding the 'id' name/value pair in the URL
querystring. This works well.

However, I've noticed that all subsequent posts back to the page
retain the querystring. So if a user presses another button on the
form, .NET reposts this URL: mypage.aspx?id=foo (and my page_load
code is executed again).

What I'd like to do is remove the querystring ('?id=foo') from the URL
that .NET uses on all following post backs. I tried to do this
through some of the Request objects but had no luck (most were read
only).

Does anyone know how to modify the querystring or header stored by
.NET that's used for post back events?

~ Jon

Nov 18 '05 #2
Jon,
To clear all querystrings, you can call the Request.QueryString.Clear();
To remove a specific querystring call: Request.QueryString.Remove(foo),
where foo is the string containing the name of the querystring to remove;

In your case it would be: Request.QueryString.Remove("id");

David Young

"Jon" <to****@hotmail.com> wrote in message
news:e4**************************@posting.google.c om...
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.aspx?id=foo">

When the page reloads, code in Page_Load then takes the appropriate
action based on finding the 'id' name/value pair in the URL
querystring. This works well.

However, I've noticed that all subsequent posts back to the page
retain the querystring. So if a user presses another button on the
form, .NET reposts this URL: mypage.aspx?id=foo (and my page_load
code is executed again).

What I'd like to do is remove the querystring ('?id=foo') from the URL
that .NET uses on all following post backs. I tried to do this
through some of the Request objects but had no luck (most were read
only).

Does anyone know how to modify the querystring or header stored by
.NET that's used for post back events?

~ Jon

Nov 18 '05 #3
rahter than try to remove the query string, just ignore it on a postback
(IsPostback).

-- bruce (sqlwork.com)

"Jon" <to****@hotmail.com> wrote in message
news:e4**************************@posting.google.c om...
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.aspx?id=foo">

When the page reloads, code in Page_Load then takes the appropriate
action based on finding the 'id' name/value pair in the URL
querystring. This works well.

However, I've noticed that all subsequent posts back to the page
retain the querystring. So if a user presses another button on the
form, .NET reposts this URL: mypage.aspx?id=foo (and my page_load
code is executed again).

What I'd like to do is remove the querystring ('?id=foo') from the URL
that .NET uses on all following post backs. I tried to do this
through some of the Request objects but had no luck (most were read
only).

Does anyone know how to modify the querystring or header stored by
.NET that's used for post back events?

~ Jon

Nov 18 '05 #4

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

Similar topics

1
by: boohoo | last post by:
I can't seem to do this: I want to take a query string and place two halves of the querystring into two separate dictionary objects. So... I loop through the collection of querystring items,...
5
by: mroffey | last post by:
Ok here's my problem. I'm using screenscrape to get some values from a webpage that only displays name/value pairs e.g. UserExists=1&HasDOB=1&FirstName=Mark I then want to get the individual...
12
by: Alex | last post by:
I have a question about determining if one QueryString keys exists. The idea is, if this key exists, than its presence is enough to indicate that its value is true. For example ... ...
6
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button...
2
by: Scott | last post by:
I'm trying to create a link (SEE LINK BELOW) to a pop-up window (myPopUp.asp). My problem is my sTargetPage variable is a url containing a querystring variable. When myPopUp.asp opens and I get my...
1
by: radiox | last post by:
Hi guys, I have this html file containing: <html><head> <script src="variable.js?id=1004"></script> </head><body></body></html> I also have the .js file that looks like this...
7
by: fox | last post by:
Hi, Lacking javascript knowledge, I just realized why my project has a bug. I am using ASP to loop through a set of records while it creates URLs with a querystring that has a single value pair....
2
by: Phillip Vong | last post by:
Please help. I'm a newbie. Using VS2005. I have a simple aspx page. I want the querystring being passed in to bind to a textbox in a control. How do you do this? Basically,...
3
by: Elroyskimms | last post by:
I have to encode an address which contains an ampersand (&) into a URL with various querystring parameters. The following code works fine: URLString = "www.myserver.com?AD1=" &...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
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

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.