Questions about Server.Transfer

  • Thread starter Thread starter Melissa
  • Start date Start date
M

Melissa

I'm learning about Server.Transfer to see if it will be worthwhile so we can
cut down on the number of session variables we use. And in doing a couple
of tests following the .NET Framework SDK documentation
(ms-help://MS.NETFrameworkSDKv1.1/cpguidenf/html/cpconpassingservercontrolva
luesbetweenpages.htm), the example shows having the textbox controls as
Protected, but when I tried to run the example and access the values in the
text boxes from the first page on the second page, I wasn't able too because
it said that the controls were protected. I changed them to public and it
worked, but why does the example show that they can be protected?

Also, when I ran the example and clicked a button to go to the second page,
the browser's address bar had the address of the first page when I was on
the second page. I understand why that is, but does it have to be that way?
It would be less confusing if it showed the page that was actually being
run.

I appreciate any help.

Thanks,
 
Melissa said:
Protected, but when I tried to run the example and access the values in the
text boxes from the first page on the second page, I wasn't able too because
it said that the controls were protected. I changed them to public and it
worked, but why does the example show that they can be protected?

No idea. Typo?
Also, when I ran the example and clicked a button to go to the second page,
the browser's address bar had the address of the first page when I was on
the second page. I understand why that is, but does it have to be that way?
It would be less confusing if it showed the page that was actually being
run.

The client browser is never notified of the server.transfer event; so it
still thinks it's looking at the original page it requested. The resulting
asynchronous situation can produce funky pathing issues, namely virtual
paths.
 
Protected, but when I tried to run the example and access the values in
the
text boxes from the first page on the second page, I wasn't able too because
it said that the controls were protected. I changed them to public and it
worked, but why does the example show that they can be protected

The example show using Protected Server Controls, but the class exposes
Public properties that return the values of the Protected controls.
Protected means that the properties are not exposed to any class that
doesn't inherit the class specified. That is why the Public properties are
used to expose the values in the Protected controls.
Also, when I ran the example and clicked a button to go to the second page,
the browser's address bar had the address of the first page when I was on
the second page. I understand why that is, but does it have to be that way?
It would be less confusing if it showed the page that was actually being
run.

If you want that, you will have to use Response.Redirect. The address shown
in the browser's address window is the address of the URL that was
requested. Server.Transfer happens on the server side, not on the client.
Response.Redirect sends a response header to the browser telling it to
request another URL.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
Back
Top