Adding name-value pair to QueryString Collection?

G

Guest

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 [using
Response.Redirect(String.Concat("WebForm2.aspx?", **a function that
re-creates the QueryString **)].

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 collection, since I will need the value in
WebForm2.aspx. I, however, have found that the QueryString's NameValue
collection is read-only.

Does anyone know how I can do this? Is there a better way?
 
R

Ravi Ambros Wallau

Didn't understand.
When you call Response.Redirect, you says that a function that recreates
query string is called. Can't you place _formSessionId=something as a
parameter for next page?
Can't you have a custom collection (that is a copy of the QueryString
collection) to do that, and is editable?
And, the better thing to do, why don't you use a Session to persist data
between different posts? It's the better way to do this.
It will be automatically loaded when you get into there...
 
G

Guest

Hi Ravi.

Thanks for your response. Please see below. I would appreciate any more
help that you can offer.
--
Joe


Ravi Ambros Wallau said:
Didn't understand.
When you call Response.Redirect, you says that a function that recreates
query string is called. Can't you place _formSessionId=something as a
parameter for next page?

The function is called in the Button's click event when the form posts back
to the server. I need it before the function is called. I need it in the
page's Load event.

Basically what I want to do is check the QueryString in the Load event for
the FormSessionId key. If it's there, I'll use it to retrieve some data for
the page. If it's not, I'll retrieve it from the database and add it to the
QueryString's NameValue collection.
Can't you have a custom collection (that is a copy of the QueryString
collection) to do that, and is editable?

How would you do this? More importantly, how would you make this custom
collection the QueryString?
And, the better thing to do, why don't you use a Session to persist data
between different posts? It's the better way to do this.
It will be automatically loaded when you get into there...

I agree that Session would be best, but I can't use Session, Cache,
ViewSatte, etc. I must use QueryString or hidden field. Client Requirement.
Joe said:
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 [using
Response.Redirect(String.Concat("WebForm2.aspx?", **a function that
re-creates the QueryString **)].

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 collection, since I will need the value in
WebForm2.aspx. I, however, have found that the QueryString's NameValue
collection is read-only.

Does anyone know how I can do this? Is there a better way?
 
R

Ravi Ambros Wallau

Hey Joe :) (that's a great song)
Well, now I think that I understand what you want to do...
No way to change QueryString, it's read only and that's your problem...
I would make a copy of Query String collection to a hashtable and then,
in the page load event, would check if the formSessionId variable is set or
not...
And I would use this Hashtable in the method that re-generates the query
string, to pass it to the next page...

It's not much harder to do, and as far as I know there's no other way
(there are other ways, but are simillar to this)...

Joe said:
Hi Ravi.

Thanks for your response. Please see below. I would appreciate any more
help that you can offer.
--
Joe


Ravi Ambros Wallau said:
Didn't understand.
When you call Response.Redirect, you says that a function that recreates
query string is called. Can't you place _formSessionId=something as a
parameter for next page?

The function is called in the Button's click event when the form posts
back
to the server. I need it before the function is called. I need it in the
page's Load event.

Basically what I want to do is check the QueryString in the Load event for
the FormSessionId key. If it's there, I'll use it to retrieve some data
for
the page. If it's not, I'll retrieve it from the database and add it to
the
QueryString's NameValue collection.
Can't you have a custom collection (that is a copy of the QueryString
collection) to do that, and is editable?

How would you do this? More importantly, how would you make this custom
collection the QueryString?
And, the better thing to do, why don't you use a Session to persist data
between different posts? It's the better way to do this.
It will be automatically loaded when you get into there...

I agree that Session would be best, but I can't use Session, Cache,
ViewSatte, etc. I must use QueryString or hidden field. Client
Requirement.
Joe said:
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 [using
Response.Redirect(String.Concat("WebForm2.aspx?", **a function that
re-creates the QueryString **)].

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 collection, since I will need the value in
WebForm2.aspx. I, however, have found that the QueryString's NameValue
collection is read-only.

Does anyone know how I can do this? Is there a better way?
 
G

Guest

Hey Ravi.

One more question: is my only option to navigate to the next page
Response.Redirect or are there others ?
--
Joe


Ravi Ambros Wallau said:
Hey Joe :) (that's a great song)
Well, now I think that I understand what you want to do...
No way to change QueryString, it's read only and that's your problem...
I would make a copy of Query String collection to a hashtable and then,
in the page load event, would check if the formSessionId variable is set or
not...
And I would use this Hashtable in the method that re-generates the query
string, to pass it to the next page...

It's not much harder to do, and as far as I know there's no other way
(there are other ways, but are simillar to this)...

Joe said:
Hi Ravi.

Thanks for your response. Please see below. I would appreciate any more
help that you can offer.
--
Joe


Ravi Ambros Wallau said:
Didn't understand.
When you call Response.Redirect, you says that a function that recreates
query string is called. Can't you place _formSessionId=something as a
parameter for next page?

The function is called in the Button's click event when the form posts
back
to the server. I need it before the function is called. I need it in the
page's Load event.

Basically what I want to do is check the QueryString in the Load event for
the FormSessionId key. If it's there, I'll use it to retrieve some data
for
the page. If it's not, I'll retrieve it from the database and add it to
the
QueryString's NameValue collection.
Can't you have a custom collection (that is a copy of the QueryString
collection) to do that, and is editable?

How would you do this? More importantly, how would you make this custom
collection the QueryString?
And, the better thing to do, why don't you use a Session to persist data
between different posts? It's the better way to do this.
It will be automatically loaded when you get into there...

I agree that Session would be best, but I can't use Session, Cache,
ViewSatte, etc. I must use QueryString or hidden field. Client
Requirement.
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 [using
Response.Redirect(String.Concat("WebForm2.aspx?", **a function that
re-creates the QueryString **)].

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 collection, since I will need the value in
WebForm2.aspx. I, however, have found that the QueryString's NameValue
collection is read-only.

Does anyone know how I can do this? Is there a better way?
 
P

Peter Rilling

Why not just concatenate it with the url, for instance
"Webform2.aspx?sessid=" + _formSessionId.
 
R

Ravi Ambros Wallau

You haver Server.Transfer as well...
Response.Redirect is processed in the browser;
Server.Transfer is processed at the server (the new page is processed and
the result of that page is passed to the browser, as it was the result of
the first page request) - it's faster, but I don't know if it's the best
choice (history, etc...)

Joe said:
Hey Ravi.

One more question: is my only option to navigate to the next page
Response.Redirect or are there others ?
--
Joe


Ravi Ambros Wallau said:
Hey Joe :) (that's a great song)
Well, now I think that I understand what you want to do...
No way to change QueryString, it's read only and that's your
problem...
I would make a copy of Query String collection to a hashtable and
then,
in the page load event, would check if the formSessionId variable is set
or
not...
And I would use this Hashtable in the method that re-generates the
query
string, to pass it to the next page...

It's not much harder to do, and as far as I know there's no other way
(there are other ways, but are simillar to this)...

Joe said:
Hi Ravi.

Thanks for your response. Please see below. I would appreciate any
more
help that you can offer.
--
Joe


:

Didn't understand.
When you call Response.Redirect, you says that a function that
recreates
query string is called. Can't you place _formSessionId=something as a
parameter for next page?

The function is called in the Button's click event when the form posts
back
to the server. I need it before the function is called. I need it in
the
page's Load event.

Basically what I want to do is check the QueryString in the Load event
for
the FormSessionId key. If it's there, I'll use it to retrieve some
data
for
the page. If it's not, I'll retrieve it from the database and add it
to
the
QueryString's NameValue collection.

Can't you have a custom collection (that is a copy of the QueryString
collection) to do that, and is editable?

How would you do this? More importantly, how would you make this
custom
collection the QueryString?

And, the better thing to do, why don't you use a Session to persist
data
between different posts? It's the better way to do this.
It will be automatically loaded when you get into there...

I agree that Session would be best, but I can't use Session, Cache,
ViewSatte, etc. I must use QueryString or hidden field. Client
Requirement.


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 [using
Response.Redirect(String.Concat("WebForm2.aspx?", **a function that
re-creates the QueryString **)].

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 collection, since I will need the value in
WebForm2.aspx. I, however, have found that the QueryString's
NameValue
collection is read-only.

Does anyone know how I can do this? Is there a better way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top