server.transfer - access posted values after they r modified

G

Guest

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.
 
B

Bruce Barker

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)
 
G

Guest

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
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top