Problems with Server.Transfer

  • Thread starter Thread starter Cathie
  • Start date Start date
C

Cathie

Hi guys,

I want to do a Server.Transfer to get to a second page, so that I may
retrieve variables I have set in the first page. I'm doing that with the
usual Server.Transfer("pagename", true). My problems are as follows:

1. On the initial load everything seems to be referencing from the first
page. For example, my style sheet I reference using "../../styles.css" but
it seems to need "../styles.css" as the first page is one step higher. When
I do anything on my page it fixes itself up. Is there a way to get around
this without hard coding the URL as I cannot be sure of the initial path?

2. When I finish with this page I want to go back to where I have come from
by pressing a button. How can I do this?

Thanks in advance,
Cathie
 
Oops I also forgot one other problem:

3. For some reason when I do a Server.Transfer back to the page I came from
(first attempt at executing 2) I lose the jscript includes on the first
page. What is happening here?
 
Cathie,

1. since you have a varying directory structure the path for css would
change correspondingly
if however you do not wish to be hassled by have to worry bout relative path
consider using an absolute path for css
one way would be to use ~ which converts to application path at run time.
if the css is located in styles directory under your root. consider using
"~/styles/styles.css"
from anywhere within the application this would correctly map to the precise
location.

2. I am not sure if you would be able to use Request.UrlReferrer variable as
you are using Server.Transfer
The way i normally do it is that on say edit for a item, i do a
response.redirect and since the request from the resource originates from
the client
on the Edit page's Page Load i set a variable in viewstate which refers to
the url of the referrer
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

Now when the user clicks submit or cancel, i perform the task and i check
the value for ViewState["URLReferrer"] if it is not null i again to a
response.redirect to that url
if(ViewState["URLReferrer"] != null)
Response.Redirect(ViewState["URLReferrer"].toString());

hope this helps...
 
Is there a way to get around
this without hard coding the URL as I cannot be sure of the initial path?

Simply use absolute paths.
____________________________________
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
DigitallySmooth Inc. | Quick Site Studio
 
Thanks for your advice. Unfortunately the ~ isn't working for me. It
doesn't seem to recognise it. Have you ever had this problem?

Hermit Dave said:
Cathie,

1. since you have a varying directory structure the path for css would
change correspondingly
if however you do not wish to be hassled by have to worry bout relative path
consider using an absolute path for css
one way would be to use ~ which converts to application path at run time.
if the css is located in styles directory under your root. consider using
"~/styles/styles.css"
from anywhere within the application this would correctly map to the precise
location.

2. I am not sure if you would be able to use Request.UrlReferrer variable as
you are using Server.Transfer
The way i normally do it is that on say edit for a item, i do a
response.redirect and since the request from the resource originates from
the client
on the Edit page's Page Load i set a variable in viewstate which refers to
the url of the referrer
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

Now when the user clicks submit or cancel, i perform the task and i check
the value for ViewState["URLReferrer"] if it is not null i again to a
response.redirect to that url
if(ViewState["URLReferrer"] != null)
Response.Redirect(ViewState["URLReferrer"].toString());

hope this helps...

--
Regards,
HD
Once a Geek.... Always a Geek
Cathie said:
Hi guys,

I want to do a Server.Transfer to get to a second page, so that I may
retrieve variables I have set in the first page. I'm doing that with the
usual Server.Transfer("pagename", true). My problems are as follows:

1. On the initial load everything seems to be referencing from the first
page. For example, my style sheet I reference using "../../styles.css" but
it seems to need "../styles.css" as the first page is one step higher.
When
I do anything on my page it fixes itself up. Is there a way to get around
this without hard coding the URL as I cannot be sure of the initial path?

2. When I finish with this page I want to go back to where I have come
from
by pressing a button. How can I do this?

Thanks in advance,
Cathie
 
try converting the style tag to a server control ie a generic html control
put in id=style1 runat="server"
and see what happens...
leaving for work right now.. if you still have a problem i will try and sort
it in half an hours time

--
Regards,
HD
Once a Geek.... Always a Geek
Cathie said:
Thanks for your advice. Unfortunately the ~ isn't working for me. It
doesn't seem to recognise it. Have you ever had this problem?

Hermit Dave said:
Cathie,

1. since you have a varying directory structure the path for css would
change correspondingly
if however you do not wish to be hassled by have to worry bout relative path
consider using an absolute path for css
one way would be to use ~ which converts to application path at run time.
if the css is located in styles directory under your root. consider using
"~/styles/styles.css"
from anywhere within the application this would correctly map to the precise
location.

2. I am not sure if you would be able to use Request.UrlReferrer variable as
you are using Server.Transfer
The way i normally do it is that on say edit for a item, i do a
response.redirect and since the request from the resource originates from
the client
on the Edit page's Page Load i set a variable in viewstate which refers
to
the url of the referrer
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

Now when the user clicks submit or cancel, i perform the task and i check
the value for ViewState["URLReferrer"] if it is not null i again to a
response.redirect to that url
if(ViewState["URLReferrer"] != null)
Response.Redirect(ViewState["URLReferrer"].toString());

hope this helps...

--
Regards,
HD
Once a Geek.... Always a Geek
Cathie said:
Hi guys,

I want to do a Server.Transfer to get to a second page, so that I may
retrieve variables I have set in the first page. I'm doing that with the
usual Server.Transfer("pagename", true). My problems are as follows:

1. On the initial load everything seems to be referencing from the
first
page. For example, my style sheet I reference using "../../styles.css" but
it seems to need "../styles.css" as the first page is one step higher.
When
I do anything on my page it fixes itself up. Is there a way to get around
this without hard coding the URL as I cannot be sure of the initial path?

2. When I finish with this page I want to go back to where I have come
from
by pressing a button. How can I do this?

Thanks in advance,
Cathie
 
Cathie,

Did you get anywhere with your problem ?

--

Regards,
HD
Hermit Dave said:
try converting the style tag to a server control ie a generic html control
put in id=style1 runat="server"
and see what happens...
leaving for work right now.. if you still have a problem i will try and
sort it in half an hours time

--
Regards,
HD
Once a Geek.... Always a Geek
Cathie said:
Thanks for your advice. Unfortunately the ~ isn't working for me. It
doesn't seem to recognise it. Have you ever had this problem?

Hermit Dave said:
Cathie,

1. since you have a varying directory structure the path for css would
change correspondingly
if however you do not wish to be hassled by have to worry bout relative path
consider using an absolute path for css
one way would be to use ~ which converts to application path at run
time.
if the css is located in styles directory under your root. consider
using
"~/styles/styles.css"
from anywhere within the application this would correctly map to the precise
location.

2. I am not sure if you would be able to use Request.UrlReferrer
variable as
you are using Server.Transfer
The way i normally do it is that on say edit for a item, i do a
response.redirect and since the request from the resource originates
from
the client
on the Edit page's Page Load i set a variable in viewstate which refers
to
the url of the referrer
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

Now when the user clicks submit or cancel, i perform the task and i
check
the value for ViewState["URLReferrer"] if it is not null i again to a
response.redirect to that url
if(ViewState["URLReferrer"] != null)
Response.Redirect(ViewState["URLReferrer"].toString());

hope this helps...

--
Regards,
HD
Once a Geek.... Always a Geek
Hi guys,

I want to do a Server.Transfer to get to a second page, so that I may
retrieve variables I have set in the first page. I'm doing that with the
usual Server.Transfer("pagename", true). My problems are as follows:

1. On the initial load everything seems to be referencing from the
first
page. For example, my style sheet I reference using "../../styles.css" but
it seems to need "../styles.css" as the first page is one step higher.
When
I do anything on my page it fixes itself up. Is there a way to get around
this without hard coding the URL as I cannot be sure of the initial path?

2. When I finish with this page I want to go back to where I have come
from
by pressing a button. How can I do this?

Thanks in advance,
Cathie
 
Thank you for your help. I couldn't get it to work but I decided to use
Response.Redirect instead and save the necessary variables to Session, this
gets rid of the relative referencing problem.

Sorry I didn't answer you last night but I went home before your last email.
Cathie.

Hermit Dave said:
Cathie,

Did you get anywhere with your problem ?

--

Regards,
HD
Hermit Dave said:
try converting the style tag to a server control ie a generic html control
put in id=style1 runat="server"
and see what happens...
leaving for work right now.. if you still have a problem i will try and
sort it in half an hours time

--
Regards,
HD
Once a Geek.... Always a Geek
Cathie said:
Thanks for your advice. Unfortunately the ~ isn't working for me. It
doesn't seem to recognise it. Have you ever had this problem?

Cathie,

1. since you have a varying directory structure the path for css would
change correspondingly
if however you do not wish to be hassled by have to worry bout relative
path
consider using an absolute path for css
one way would be to use ~ which converts to application path at run
time.
if the css is located in styles directory under your root. consider
using
"~/styles/styles.css"
from anywhere within the application this would correctly map to the
precise
location.

2. I am not sure if you would be able to use Request.UrlReferrer
variable
as
you are using Server.Transfer
The way i normally do it is that on say edit for a item, i do a
response.redirect and since the request from the resource originates
from
the client
on the Edit page's Page Load i set a variable in viewstate which refers
to
the url of the referrer
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

Now when the user clicks submit or cancel, i perform the task and i
check
the value for ViewState["URLReferrer"] if it is not null i again to a
response.redirect to that url
if(ViewState["URLReferrer"] != null)
Response.Redirect(ViewState["URLReferrer"].toString());

hope this helps...

--
Regards,
HD
Once a Geek.... Always a Geek
Hi guys,

I want to do a Server.Transfer to get to a second page, so that I may
retrieve variables I have set in the first page. I'm doing that with
the
usual Server.Transfer("pagename", true). My problems are as follows:

1. On the initial load everything seems to be referencing from the
first
page. For example, my style sheet I reference using "../../styles.css"
but
it seems to need "../styles.css" as the first page is one step higher.
When
I do anything on my page it fixes itself up. Is there a way to get
around
this without hard coding the URL as I cannot be sure of the initial
path?

2. When I finish with this page I want to go back to where I have come
from
by pressing a button. How can I do this?

Thanks in advance,
Cathie
 
Thank you for the update Cathie.
The response.redirect is a better choice specially when you consider the
client using browsers Back button. That sort of messes a few things up
(browser not knowing about internal transfer) if you use Server.Transfer
As for not replying the post earlier, its alright, time zones!!! getting
used to them over the years.
Glad that atleast in a way you have the code working.

--
Regards,
HD
Once a Geek.... Always a Geek
Cathie said:
Thank you for your help. I couldn't get it to work but I decided to use
Response.Redirect instead and save the necessary variables to Session,
this
gets rid of the relative referencing problem.

Sorry I didn't answer you last night but I went home before your last
email.
Cathie.

Hermit Dave said:
Cathie,

Did you get anywhere with your problem ?

--

Regards,
HD
Hermit Dave said:
try converting the style tag to a server control ie a generic html control
put in id=style1 runat="server"
and see what happens...
leaving for work right now.. if you still have a problem i will try and
sort it in half an hours time

--
Regards,
HD
Once a Geek.... Always a Geek
Thanks for your advice. Unfortunately the ~ isn't working for me. It
doesn't seem to recognise it. Have you ever had this problem?

Cathie,

1. since you have a varying directory structure the path for css
would
change correspondingly
if however you do not wish to be hassled by have to worry bout relative
path
consider using an absolute path for css
one way would be to use ~ which converts to application path at run
time.
if the css is located in styles directory under your root. consider
using
"~/styles/styles.css"
from anywhere within the application this would correctly map to the
precise
location.

2. I am not sure if you would be able to use Request.UrlReferrer
variable
as
you are using Server.Transfer
The way i normally do it is that on say edit for a item, i do a
response.redirect and since the request from the resource originates
from
the client
on the Edit page's Page Load i set a variable in viewstate which refers
to
the url of the referrer
if(!Page.IsPostback)
{
ViewState["URLReferrer"] = Request.UrlReferrer;
}

Now when the user clicks submit or cancel, i perform the task and i
check
the value for ViewState["URLReferrer"] if it is not null i again to a
response.redirect to that url
if(ViewState["URLReferrer"] != null)
Response.Redirect(ViewState["URLReferrer"].toString());

hope this helps...

--
Regards,
HD
Once a Geek.... Always a Geek
Hi guys,

I want to do a Server.Transfer to get to a second page, so that I may
retrieve variables I have set in the first page. I'm doing that with
the
usual Server.Transfer("pagename", true). My problems are as follows:

1. On the initial load everything seems to be referencing from the
first
page. For example, my style sheet I reference using "../../styles.css"
but
it seems to need "../styles.css" as the first page is one step higher.
When
I do anything on my page it fixes itself up. Is there a way to get
around
this without hard coding the URL as I cannot be sure of the initial
path?

2. When I finish with this page I want to go back to where I have come
from
by pressing a button. How can I do this?

Thanks in advance,
Cathie
 
Back
Top