473,748 Members | 3,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to clear parameter out of url

I'm passing a parameter in the url when I open up a particular page. When
the page loads and finds this parameter, I know that I need to clear a
variable out of the session cache and reset it with a new value. On the
following postbacks I want this variable to remain constant which means I
need to clear the parameter out of the URL before any of the postbacks
occur. Otherwise if this parameter is still in the URL when the page loads
from a postback, it will clear out the variable again.

is there a way to alter the pages current URL?

--
mo*******@nospa m.com
Nov 18 '05 #1
4 4939
Hi Moondaddy,

From your description, one of your ASP.NET web page will checking a certain
querystring parameter in the requested url and do some session operations
depending on the parameter value. And currently you want to remove the
certain parameter from the request url if it exist in the first request, so
that the following postback request won't do the duplicated operations on
the session ,yes?

As far as I know, the QueryString collection of the Request object are not
modifiable by user, and I think you can consider the following means:
1.Still let the querystring param remain in the url and use the
Page.IsPostBack property to check whether its the first time loaded or post
back request so as to determine whether to do the session modification or
not.

2. User Server.Transfer or response.Redire ct to reload the current page
with the non-querystring url. But this will reduce the performance.

Please have a consider on the above things. If you have any other different
ideas, please also feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #2
Thanks for the 2 options. #1 would be cleaner and I think I avoided some of
its performance hit by running the logic in the Page_Init method before the
line InitializeComon ent executed. I used a 'redirect' and 'return' before
InitializeComon ent could run. However, I ended up using #2 as it seemed to
still be a wee bit faster (although I couldn't really tell by just watching
them both run).

Thanks for the help.

--
mo*******@nospa m.com
"Steven Cheng[MSFT]" <v-******@online.m icrosoft.com> wrote in message
news:em******** ******@cpmsftng xa10.phx.gbl...
Hi Moondaddy,

From your description, one of your ASP.NET web page will checking a certain querystring parameter in the requested url and do some session operations
depending on the parameter value. And currently you want to remove the
certain parameter from the request url if it exist in the first request, so that the following postback request won't do the duplicated operations on
the session ,yes?

As far as I know, the QueryString collection of the Request object are not
modifiable by user, and I think you can consider the following means:
1.Still let the querystring param remain in the url and use the
Page.IsPostBack property to check whether its the first time loaded or post back request so as to determine whether to do the session modification or
not.

2. User Server.Transfer or response.Redire ct to reload the current page
with the non-querystring url. But this will reduce the performance.

Please have a consider on the above things. If you have any other different ideas, please also feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
"moondaddy" <mo*******@nosp am.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
I'm passing a parameter in the url when I open up a particular page. When
the page loads and finds this parameter, I know that I need to clear a
variable out of the session cache and reset it with a new value. On the
following postbacks I want this variable to remain constant which means I
need to clear the parameter out of the URL before any of the postbacks
occur. Otherwise if this parameter is still in the URL when the page loads from a postback, it will clear out the variable again.

is there a way to alter the pages current URL?


If you only need that query parameter the first time you open the page, then
you should only check it on the first request. Use:

If Not Page.IsPostBack Then
If Request.QuerySt ring("onceonly" ) = "doThisOnce " Then
...
End If
End If
--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #4
"moondaddy" <mo*******@nosp am.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
I'm passing a parameter in the url when I open up a particular page. When
the page loads and finds this parameter, I know that I need to clear a
variable out of the session cache and reset it with a new value. On the
following postbacks I want this variable to remain constant which means I
need to clear the parameter out of the URL before any of the postbacks
occur. Otherwise if this parameter is still in the URL when the page loads from a postback, it will clear out the variable again.

is there a way to alter the pages current URL?


If you only need that query parameter the first time you open the page, then
you should only check it on the first request. Use:

If Not Page.IsPostBack Then
If Request.QuerySt ring("onceonly" ) = "doThisOnce " Then
...
End If
End If
--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #5

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

Similar topics

3
16946
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can create a parameter query in a stored procedure, but how do I use the result set of a parameter query in a select query (in the same or another sp)? In short, if a select query contains a result table that is generated as a parameter query, how do I...
4
9557
by: Weeepie | last post by:
Hello, Is it possible to clear a datagrid in VBdotNET? I'm using a query to fill the datagrid, but when I change the parameter, the next query follows the previous. Is there someone who can help me. Thx, Weeepie.
10
5563
by: mttc | last post by:
I read articles that suggest preventing delete by throwing Exception from RowDeleting Event. I not understand where I can catch this Error?
10
14108
by: ypjofficial | last post by:
Hello All, In my program I am using a pointer to a vector vector<XYZ> * vptr = new vector<XYZ>; and also the XYZ class has a char* as one of its member.I have created all the copy constructor, assignment operator and destructor (The Big Three ) for XYZ. My question is how to free the memory held by vptr?
3
1405
by: aziz001DETESTSPAM | last post by:
I've been following some tutorials and reading books and have a basic grasp of the fundamental ADO.NET commands. But all the books I've read use a database with only 1 table. My database has many, so: 1. I know there is 1 OleDbConnectino object variable per database file, but is there one dataAdapter per table/query? (e.g. my tables: tblCustomer, tblProducts, tblPrices etc etc, so should I have dataAdapters such as these?...
3
22379
by: nitinp | last post by:
I want to bind GridView with sqlDataSource like following sqlDataSource1.SelectCommand = "GET_TRACKING_INFO"; sqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure; sqlDataSource1.SelectParameters.Add("Group_code",TypeCode.String, "1"); sqlDataSource1.SelectParameters.Direction =ParameterDirection.Input; GridView1.DataSource = sqlDataSource1; GridView1.DataBind();
16
3163
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the parameter will not be changed - so don't worry. 2. It tells the implementor and the maintainer of this function that the parameter should not be changed inside the function. And it is for this reason that some people advocate that it is a good idea to...
1
2290
by: Norman Chong | last post by:
Hi, I need an application which clears the cache of the internet explorer and found the code for this on http://support.microsoft.com/kb/311289/en Problem: The end of the loop below is never reached so the program is blocked. Reason: Marshal.GetLastWin32Error() always returns code 87 ("The parameter is incorrect.") which doesn't
4
2248
by: moondaddy | last post by:
Using c# 3.5, what's the best way to remove the contents of a stringbuilder object? I was using this code: sb.Remove(1, sb.Length - 1); but when it had 9 carriage returns in it like this: "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n" I got the error: System.ArgumentOutOfRangeException: Length cannot be less than zero.
0
8991
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
8830
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
9544
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
9372
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
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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
6074
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
4606
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...
2
2783
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.