Can an aspx page set its own URL?

T

TR

I want to create a "container" page which figures out what existing URL
to display based on a value in the query string. The page will do a
database lookup using that query string value, and retrieve the URL-to-
be-displayed from the database.

Is it possible at some point for MyContainerPage.aspx to specify its
document.URL property, or something similar, so that document.URL would
point to "http://www.someotherdomain.com", perhaps in a registered
startup script block using <body onload="mystartupscript()">?

Thanks
TR
 
S

Scott Mitchell [MVP]

TR said:
I want to create a "container" page which figures out what existing URL
to display based on a value in the query string. The page will do a
database lookup using that query string value, and retrieve the URL-to-
be-displayed from the database.

Is it possible at some point for MyContainerPage.aspx to specify its
document.URL property, or something similar, so that document.URL would
point to "http://www.someotherdomain.com", perhaps in a registered
startup script block using <body onload="mystartupscript()">?

You can redirect the user's browser to a different URL using
Response.Redirect(url) in your Page_Load event handler. Is this what
you're after?

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
T

TR

Hi Scott,
Thanks for the reply and the suggestion, but redirecting is not
what I'm trying to do; but now that I've been working on the
problem and am closer to a solution, I can describe the issue more
clearly. First, I'll give you The Scenario (sorry if it's prolix)
and then The Problem.

THE SCENARIO
We have a lot of documents that were converted to html. They're
stored on our server, in the file system, and have names like
"doc123.htm". They are barebones HTML, like this:

<HTML><HEAD></HEAD><BODY>content ... </BODY></HTML>

In our SQL Database, we have the documents coded by topics, and
also the full path to where they can be found. They're in
different directories, e.g.:

\webapps
\international
\travel
\medicine
\visas

When users visit our site, they search for a topic. Our menu.aspx
issues a call to the database and retrieves the ids and titles of
the matching documents, e.g.:

doc123 | Travel in Asia
doc456 | Innoculations Required for Travel in Asia

buiding hyperlinks to these items. The user clicks on the link to
retrieve the document. We have another page, launcher.aspx, which
is "called" by menu.aspx like this:

[pseudocode]
<script>
window.open(launcher.aspx?id=doc123, ....)
</script>

Launcher.aspx in turn does this:

-- gets the query string
-- determines the id of the document to display (doc123)
-- calls the database to find out where doc123 can be found in
the file system and then builds the URL
-- registers a startup script:
mystartupscript() {
window.location = {the full url for doc123.htm}
}

Thus, Launcher.aspx displays doc123.htm.


THE PROBLEM
These HTML documents are bare-bones text, without banners or
footers, so I'd like to display the contents of doc123.htm
*inside* a DIV if possible, rather than setting window.location =
{the full URL for doc123}

[Launcher.aspx]
..
..
..
<BODY onload='mystartupscript'>

<DIV id='banner'>
</DIV>
<DIV id='content'>
<!-- here's where doc123.htm's contents
i.e. what is inside its <BODY></BODY> tags
should be displayed -->
</DIV>
<DIV id='footer'>
</DIV>
</BODY>


Is this possible? Do I have to read doc123.htm as a stream, strip
off its <HTML><BODY> and corresponding closing tags, and inject
the HTML byte-stream into the DIV whose ID = 'content' ? Or is
there an easier way? I'd like to avoid FRAMES if possible.

Thanks!
TR
 

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
474,121
Messages
2,570,712
Members
47,283
Latest member
hopkins1988

Latest Threads

Top