468,766 Members | 1,345 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,766 developers. It's quick & easy.

server.transfer - access posted values after they r modified

P K
I am using server.transfer for a website being developed in vs.net 2005
And I need to get the posted values after server.transfer. For this I set
the second parameter "true" in the transfer method. Also enableViewStateMac
is made false in the destination page. Still I cannot get some changed values.

The scenario is such -
1. I have page 1 with a hidden variable named,"myHid" whose value is set to
"Text1"

2. When a submit happens on page1 to the same page, on page_load after
postback I do some database manipulations and then change the text of the
hidden variable to "Text2"
3. After this I do - server.transfer("page2.aspx",true)
4. In page2.aspx on page load I try to access the hiddenvariable using
request.params("myHid"). Doing this gives me the value "Text1". I do not get
the value "Text2".

Is this because in page_load just before transfer I modified the value and
by then the Post had already happened.
If so, what is the solution to access posted values even after they are
changed after postback.
Nov 19 '05 #1
2 1585
server transfer works by creating an instance of the new page and re-running
the page process logic with the new instance. the actual postback values in
the request are readonly. when you update a control (say your hidden), you
are updating it internal value, not the postback value.

if you want to access the value after update, on you original page supply
some public properties to return them, then access these from the
transferred page. the original page is accessed thru Context.Handler.

in asp.net 2.0, the code behinds are separate dll's, so you can not
reference them like in 1.0. this means you should create an interface with
the public properties that the page implements. the interface definition
should be in a file in the app_code directory.
-- bruce (sqlwork.com)


"P K" <P K@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
I am using server.transfer for a website being developed in vs.net 2005
And I need to get the posted values after server.transfer. For this I set
the second parameter "true" in the transfer method. Also
enableViewStateMac
is made false in the destination page. Still I cannot get some changed
values.

The scenario is such -
1. I have page 1 with a hidden variable named,"myHid" whose value is set
to
"Text1"

2. When a submit happens on page1 to the same page, on page_load after
postback I do some database manipulations and then change the text of the
hidden variable to "Text2"
3. After this I do - server.transfer("page2.aspx",true)
4. In page2.aspx on page load I try to access the hiddenvariable using
request.params("myHid"). Doing this gives me the value "Text1". I do not
get
the value "Text2".

Is this because in page_load just before transfer I modified the value and
by then the Post had already happened.
If so, what is the solution to access posted values even after they are
changed after postback.

Nov 19 '05 #2
P K
Hey Bruce,

Thanks for that one.Thats sounds sensible. Is there a complete working
example some where? I have got stuck while creating properties.

e.g.
'Protected myHid As System.Web.UI.WebControls.HiddenField
Public ReadOnly Property Hidden() As String
Get
Return Me.myHid.Value
End Get

If I do not declare the protected variable, while creating the dll for the
code behinds vbc does not recognize the myHid variable. If I uncomment it,
the aspx build fails saying that there already is a Protected myHid variable
on the page. ( I have it on the aspx page).

Some confusion there. A complete example would help.

P.K

"Bruce Barker" wrote:
server transfer works by creating an instance of the new page and re-running
the page process logic with the new instance. the actual postback values in
the request are readonly. when you update a control (say your hidden), you
are updating it internal value, not the postback value.

if you want to access the value after update, on you original page supply
some public properties to return them, then access these from the
transferred page. the original page is accessed thru Context.Handler.

in asp.net 2.0, the code behinds are separate dll's, so you can not
reference them like in 1.0. this means you should create an interface with
the public properties that the page implements. the interface definition
should be in a file in the app_code directory.
-- bruce (sqlwork.com)


"P K" <P K@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
I am using server.transfer for a website being developed in vs.net 2005
And I need to get the posted values after server.transfer. For this I set
the second parameter "true" in the transfer method. Also
enableViewStateMac
is made false in the destination page. Still I cannot get some changed
values.

The scenario is such -
1. I have page 1 with a hidden variable named,"myHid" whose value is set
to
"Text1"

2. When a submit happens on page1 to the same page, on page_load after
postback I do some database manipulations and then change the text of the
hidden variable to "Text2"
3. After this I do - server.transfer("page2.aspx",true)
4. In page2.aspx on page load I try to access the hiddenvariable using
request.params("myHid"). Doing this gives me the value "Text1". I do not
get
the value "Text2".

Is this because in page_load just before transfer I modified the value and
by then the Post had already happened.
If so, what is the solution to access posted values even after they are
changed after postback.


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Tom | last post: by
2 posts views Thread by Melissa | last post: by
1 post views Thread by olduncleamos | last post: by
23 posts views Thread by barryfz | last post: by
2 posts views Thread by CCY | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.