473,811 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.as px?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 12682
You could always Response.Redire ct 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.goo gle.com...
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.as px?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.QuerySt ring.Clear();
To remove a specific querystring call: Request.QuerySt ring.Remove(foo ),
where foo is the string containing the name of the querystring to remove;

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

David Young

"Jon" <to****@hotmail .com> wrote in message
news:e4******** *************** ***@posting.goo gle.com...
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.as px?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.goo gle.com...
Hi,

I have hyperlink objects in a datagrid that redirect the user back to
the current page with this syntax:
<a href="mypage.as px?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
2947
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, right? When I get to a certain item in the querystring, all items after that are to be put into the SECOND dictionary object.
5
6550
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 values from these and split them up and use in some stored procs. Is there a way I can pass these values into a querystring object and then request them? e.g. NameValueCollection coll = Request.QueryString;
12
5296
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 ... www.something.com/main.aspx?client Client is the QueryString, but no value is given. This would mean to me that client exists, so its value is true. In the code behind, I can tell that client exists using Request.QueryString.Keys.Count, which equals 1....
6
1795
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 server control that ultimately redirects him/her to WebForm2.aspx . I need to persist the value of _formSessionId between the initial post and the postback (after the Button control is clicked). I would like to add the value to the QueryString...
2
1667
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 sPage query string value, it returns myTargetpage.asp?qs=1 and clips the 2nd querystring value pair. Can someone help me construct a link so myPopUp.asp preserves the entire query string? I tried using the Server.HtmlEncode comand in "FAILED...
1
1761
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
2538
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. This URL needs to open in a floating window if clicked. (this is for an administrator and so opening a small floater gives them more efficient access to the data that will be displayed). I now understand that because the ASP executes first, that...
2
1607
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, www.website.com?string=100 The site autoloads into Formview1 / InsertItem Template. TextBox1 shows up as blank waiting for me to put in the value "100", but I want Textbox1 to autograb that value and put it in. Is this possible?
3
6663
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=" & HTTPUtility.URLEncode("500 Rt 6 & 209") and then to retrieve it: txtAddress1.text = Request.Querystring("AD1") However, in a different page of code, I loop through the QueryString.AllKeys collection like this:
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
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...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
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...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
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
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
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
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.