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

Problems with Server.Transfer

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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" <so*****@miscrosoft.com> wrote in message
news:uO**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2

P: n/a
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" <so*****@miscrosoft.com> wrote in message
news:uO**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #3

P: n/a
>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
Nov 18 '05 #4

P: n/a
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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
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" <so*****@miscrosoft.com> wrote in message
news:uO**************@TK2MSFTNGP10.phx.gbl...
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


Nov 18 '05 #5

P: n/a
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" <so*****@miscrosoft.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
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" <so*****@miscrosoft.com> wrote in message
news:uO**************@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Nov 18 '05 #6

P: n/a
Cathie,

Did you get anywhere with your problem ?

--

Regards,
HD
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
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" <so*****@miscrosoft.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
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" <so*****@miscrosoft.com> wrote in message
news:uO**************@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Nov 18 '05 #7

P: n/a
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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
Cathie,

Did you get anywhere with your problem ?

--

Regards,
HD
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
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" <so*****@miscrosoft.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message news:uQ**************@TK2MSFTNGP09.phx.gbl...
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" <so*****@miscrosoft.com> wrote in message
news:uO**************@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Nov 18 '05 #8

P: n/a
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" <so*****@miscrosoft.com> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
Cathie,

Did you get anywhere with your problem ?

--

Regards,
HD
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
> 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" <so*****@miscrosoft.com> wrote in message
> news:%2******************@TK2MSFTNGP10.phx.gbl...
>> 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" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message >> news:uQ**************@TK2MSFTNGP09.phx.gbl...
>>> 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" <so*****@miscrosoft.com> wrote in message
>>> news:uO**************@TK2MSFTNGP10.phx.gbl...
>>> > 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
>>> >
>>> >
>>>
>>>
>>
>>
>
>



Nov 18 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.