By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,221 Members | 1,315 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,221 IT Pros & Developers. It's quick & easy.

Adding name-value pair to QueryString Collection?

P: n/a
Joe
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?
--
Joe
Feb 8 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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...

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
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?
--
Joe

Feb 8 '06 #2

P: n/a
Joe
Hi Ravi.

Thanks for your response. Please see below. I would appreciate any more
help that you can offer.
--
Joe
"Ravi Ambros Wallau" wrote:
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" <Jo*@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
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?
--
Joe


Feb 8 '06 #3

P: n/a
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" <Jo*@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Hi Ravi.

Thanks for your response. Please see below. I would appreciate any more
help that you can offer.
--
Joe
"Ravi Ambros Wallau" wrote:
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" <Jo*@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
> 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?
> --
> Joe


Feb 8 '06 #4

P: n/a
Joe
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" wrote:
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" <Jo*@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Hi Ravi.

Thanks for your response. Please see below. I would appreciate any more
help that you can offer.
--
Joe
"Ravi Ambros Wallau" wrote:
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" <Jo*@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
> 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?
> --
> Joe


Feb 8 '06 #5

P: n/a
Why not just concatenate it with the url, for instance
"Webform2.aspx?sessid=" + _formSessionId.

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
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?
--
Joe

Feb 8 '06 #6

P: n/a
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" <Jo*@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
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" wrote:
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" <Jo*@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
> Hi Ravi.
>
> Thanks for your response. Please see below. I would appreciate any
> more
> help that you can offer.
> --
> Joe
>
>
> "Ravi Ambros Wallau" wrote:
>
>> 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" <Jo*@discussions.microsoft.com> wrote in message
>> news:CE**********************************@microsof t.com...
>> > 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?
>> > --
>> > Joe
>>
>>
>>


Feb 8 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.