Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Clear QueryString on PostBack?

Reply
Thread Tools

Clear QueryString on PostBack?

 
 
Raterus
Guest
Posts: n/a
 
      05-28-2004
Howdy,

Simple question, but I can't figure out how to do it. I have a a page which is called initially with a querystring. After I get the querystring values, I don't need the querystring to appear in the url anymore. How can I get rid of it? A postback doesn't clear it, it just keeps tagging along. I tried Request.QueryString.Clear, but get "readonly" errors.

I want to do this, because eventually I use server.transfer within this page, and the querystring, tags along to new page as well, even after a postback on this new page. I start to get problems when, from second page, I perform a server.transfer back to the first page. My problems are explainable, if the querystring was empty, the page would work properly, but since the querystring is set, my page essentially breaks. I'm not too concerned about this, because if I could get rid of the querystring, I wouldn't have this problem!

Thanks for any help on this,
--Michael
 
Reply With Quote
 
 
 
 
Nicole Calinoiu
Guest
Posts: n/a
 
      05-28-2004
Michael,

The Server.Transfer method has an overload that allows you to specify
whether the querystring and form data should be preserved or not. Using
this appropriately should give the result you desire. Otherwise, might a
client-side redirection work for at least one of your two transfers?

HTH,
Nicole


"Raterus" <> wrote in message
news:...
Howdy,

Simple question, but I can't figure out how to do it. I have a a page which
is called initially with a querystring. After I get the querystring values,
I don't need the querystring to appear in the url anymore. How can I get
rid of it? A postback doesn't clear it, it just keeps tagging along. I
tried Request.QueryString.Clear, but get "readonly" errors.

I want to do this, because eventually I use server.transfer within this
page, and the querystring, tags along to new page as well, even after a
postback on this new page. I start to get problems when, from second page,
I perform a server.transfer back to the first page. My problems are
explainable, if the querystring was empty, the page would work properly, but
since the querystring is set, my page essentially breaks. I'm not too
concerned about this, because if I could get rid of the querystring, I
wouldn't have this problem!

Thanks for any help on this,
--Michael


 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      05-28-2004
Never knew it had that option, but unfortunately that doesn't help, as the default is "false".
I think my more explain my problem now by this example, take server.transfer out of it. After my page that uses the querystring is rendered, this appears in the html source. The postback uses the querystring, I don't want it to.

<form name="Form1" method="post" action="manage.aspx?docID=40" id="Form1">
I want it to say this
<form name="Form1" method="post" action="manage.aspx" id="Form1">

Any ideas how I can clear the querystring from being rendered like this?

--Michael

"Nicole Calinoiu" <> wrote in message news:...
> Michael,
>
> The Server.Transfer method has an overload that allows you to specify
> whether the querystring and form data should be preserved or not. Using
> this appropriately should give the result you desire. Otherwise, might a
> client-side redirection work for at least one of your two transfers?
>
> HTH,
> Nicole
>
>
> "Raterus" <> wrote in message
> news:...
> Howdy,
>
> Simple question, but I can't figure out how to do it. I have a a page which
> is called initially with a querystring. After I get the querystring values,
> I don't need the querystring to appear in the url anymore. How can I get
> rid of it? A postback doesn't clear it, it just keeps tagging along. I
> tried Request.QueryString.Clear, but get "readonly" errors.
>
> I want to do this, because eventually I use server.transfer within this
> page, and the querystring, tags along to new page as well, even after a
> postback on this new page. I start to get problems when, from second page,
> I perform a server.transfer back to the first page. My problems are
> explainable, if the querystring was empty, the page would work properly, but
> since the querystring is set, my page essentially breaks. I'm not too
> concerned about this, because if I could get rid of the querystring, I
> wouldn't have this problem!
>
> Thanks for any help on this,
> --Michael
>
>

 
Reply With Quote
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      05-28-2004
Hi

You can change the Action attribute of the form through client-side script
Please see this article on Microsoft Support
PRB: Cannot Change or Remove the QueryString Action for a Web Form on Postbac
http://support.microsoft.com/default...kb;en-us;81021

Bin Song, MCP
 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      05-28-2004
the only way to clear the querystring is a redirect. the browser does not
know you do a server transfer, it just remembers what the url (including
query string) was for the postback. to clear it you send the browser a
redirect, so that the new rendered page matchs the new url.

-- bruce (sqlwork.com)


"Raterus" <> wrote in message
news:...
Howdy,

Simple question, but I can't figure out how to do it. I have a a page which
is called initially with a querystring. After I get the querystring values,
I don't need the querystring to appear in the url anymore. How can I get
rid of it? A postback doesn't clear it, it just keeps tagging along. I
tried Request.QueryString.Clear, but get "readonly" errors.

I want to do this, because eventually I use server.transfer within this
page, and the querystring, tags along to new page as well, even after a
postback on this new page. I start to get problems when, from second page,
I perform a server.transfer back to the first page. My problems are
explainable, if the querystring was empty, the page would work properly, but
since the querystring is set, my page essentially breaks. I'm not too
concerned about this, because if I could get rid of the querystring, I
wouldn't have this problem!

Thanks for any help on this,
--Michael


 
Reply With Quote
 
mrawlingson mrawlingson is offline
Junior Member
Join Date: Jun 2009
Posts: 1
 
      06-24-2009
I know I'm a bit late on this one, but for those stumbling across this - you can change the action attribute using Form.Action in your code behind

Sample code:

if (request.querystring == "something") {
//do something
Form.Action = "this page.aspx";
}

So any time there is a further postback or any submission of the form, your querysting won't be carried over.
 
Reply With Quote
 
malbert1169 malbert1169 is offline
Junior Member
Join Date: Sep 2010
Posts: 1
 
      09-17-2010
This works PERFECTLY! Thank you, mrawlingson.

Quote:
Originally Posted by mrawlingson
I know I'm a bit late on this one, but for those stumbling across this - you can change the action attribute using Form.Action in your code behind

Sample code:

if (request.querystring == "something") {
//do something
Form.Action = "this page.aspx";
}

So any time there is a further postback or any submission of the form, your querysting won't be carried over.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.Clear() doesn't clear David ASP .Net 2 01-31-2008 08:32 PM
Unrecognized element 'add' after <clear></clear> InvalidLastName ASP .Net Web Services 3 03-06-2007 03:07 AM
How to get value of QueryString inside QueryString Mehdi ASP .Net 6 04-06-2006 03:41 PM
Passing QueryString URL as a paremeter in QueryString Adeel Ahmad ASP General 1 03-07-2006 02:05 PM
How to clear the querystring? Davids ASP .Net 5 11-15-2004 09:55 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57