asp:button and response.redirect _top

J

Jim in Arizona

I have a site that uses frames. I made an aspx form with an asp:button
control with Onclick=test. The test sub is:

Sub Test(ByVal sender As Object, ByVal e As System.EventArgs)

Response.Redirect("http://webserver/policies/pppindex.htm target=_blank")

End Sub

Of course, this will not work. Is there some way I can get a similar result
without using normal HTML? I don't want the page to load within the frame as
it would if I wrote it
response.redirect(http://webserver/policies/pppindex.htm)

Thanks for your help.
Jim
 
K

Kevin Spencer

Hi Jim,

A little about HTTP:

A Response is a response to a Request. The Request comes from a browser
instance on the client. A FrameSet has multiple browser instances. When a
frame (browser instance) sends a Request, the Response is sent back to the
same client browser instance (of course). That means that Response.Redirect,
which is a Response to a Request, is a Response to a Request from a certain
browser instance. Targeting a frame therefore, can only be done on the
client, as that is where the frames are linked by the parent browser.

What I would do is to add some JavaScript to the Response, which changes the
target frame's document.location property to the URL you want loaded into
that frame. That is, as the Response will come back to the browser instance
that sent the Request, it can refresh the page, and add a javascript to it,
something like the following:

<script type="text/javascript"><!--
parent.frameName.location = "url";
// -></script>

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
J

Jim in Arizona

Kevin Spencer said:
Hi Jim,

A little about HTTP:

A Response is a response to a Request. The Request comes from a browser
instance on the client. A FrameSet has multiple browser instances. When a
frame (browser instance) sends a Request, the Response is sent back to the
same client browser instance (of course). That means that
Response.Redirect, which is a Response to a Request, is a Response to a
Request from a certain browser instance. Targeting a frame therefore, can
only be done on the client, as that is where the frames are linked by the
parent browser.

What I would do is to add some JavaScript to the Response, which changes
the target frame's document.location property to the URL you want loaded
into that frame. That is, as the Response will come back to the browser
instance that sent the Request, it can refresh the page, and add a
javascript to it, something like the following:

<script type="text/javascript"><!--
parent.frameName.location = "url";
// -></script>

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
------snip------

I should have known better. Of course, I was hopeful in some way that there
would be some simple soulution.

I have not worked with javascipt (enough) and I'm still pretty new to vb
(newer to vb.net). I wouldn't know how to implement a script like that in
any fashion.

My normal html link from before was <a href="/policies/pppindex.htm"
target=_top>link here</a>, which of course removed all frames and loaded the
single htm page in place of the frames. When you say
parent.framename.location, I don't know what portion of that is referring to
what part of my standard link.

Would there be some other way of writing the Test Subprocedure to make my
pretty graphical button work, or am I forced to use standard HTML or
javascript?

Thanks for your help Kevin.

Jim
 
K

Kevin Spencer

Hi JJim,
My normal html link from before was <a href="/policies/pppindex.htm"
target=_top>link here</a>, which of course removed all frames and loaded
the single htm page in place of the frames. When you say
parent.framename.location, I don't know what portion of that is referring
to what part of my standard link.

Well, you could always have a regular link that goes to:

/policies/ppindex.htm target=frameName

....where "frameName" is the name of the frame you want loaded.
I have not worked with javascipt (enough) and I'm still pretty new to vb
(newer to vb.net). I wouldn't know how to implement a script like that in
any fashion.

Just one last comment: Every programmer runs into a situation in which
he/she has "not worked with " some technology, language, or other, from time
to time. The way you improve is to research the new thing when you run into
it, rather than running away from it. Just a couple of weeks ago I had the
task of adding water to a 3-D terrain mapping engine. I found the National
Land Cover Data Set on the USGS web site, but that was only the beginning.
The data was stored in GeoTiffs, which is a specialized form of Tiff file.
To make it worse, it was stored in Albers Equal Araeqa Conical projection.
Now, I knew nothing about parsing Tiff files, much less deriving Lat/Long
information from a raster image with Albers Equal Area Conical projection.
But I do now! ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
J

Jim in Arizona

Kevin Spencer said:
Hi JJim,


Well, you could always have a regular link that goes to:

/policies/ppindex.htm target=frameName

...where "frameName" is the name of the frame you want loaded.


Just one last comment: Every programmer runs into a situation in which
he/she has "not worked with " some technology, language, or other, from
time to time. The way you improve is to research the new thing when you
run into it, rather than running away from it. Just a couple of weeks ago
I had the task of adding water to a 3-D terrain mapping engine. I found
the National Land Cover Data Set on the USGS web site, but that was only
the beginning. The data was stored in GeoTiffs, which is a specialized
form of Tiff file. To make it worse, it was stored in Albers Equal Araeqa
Conical projection. Now, I knew nothing about parsing Tiff files, much
less deriving Lat/Long information from a raster image with Albers Equal
Area Conical projection. But I do now! ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.


Thanks for the insight.

I think I'm still a few days off before I open a book or pdf doc on parsing
Tiff files stored in Albers Equal Areqa Conical Projection. I tried to say
that three, then just two times fast and I couldn't do it! :)

I'll keep working on a solution. Depending on what I finally implement, I'll
let you know how it turned out. Should be amusing, and maybe informative, in
any case! :)

Jim
 
K

Kevin Spencer

I'll keep working on a solution. Depending on what I finally implement,
I'll let you know how it turned out. Should be amusing, and maybe
informative, in any case! :)

There you go man!

BTW, I misspelled "Area" - it should read "Albers Equal Area Conical
projection." For whatever that's worth!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top