Displaying ASP page in ASPX page

G

Guest

Is there a way to display/render an ASP page inside of an ASPX page with ASP
..Net 2.0? I'm not trying to back into frames but I have an application that
will allow me to customize complex rendered reports by adding parms to the
query string of an ASP page and just calling the entire URL. This works great
for web parts in SharePoint and with a Windows application, but I'm not sure
how to do it with ASP .Net. In fact, I'm looking for the exact thing that can
be done in SharePoint and that's a web part that takes a URL as an input
parm.

I'm starting to think that this just isn't possible without frames. I know
the best solution would be to not reference the ASP page but suffice to say
that's not an option due to time contraints.

Thanks.
 
G

Guest

MattM,

This is fairly easy in Sharepoint Portal Server 2003/MOSS 2007. You have
something called PageViewerWebPart that will take the url of the page to be
rendered(including query string).

The samething is feasible in ASP.NET 2.0. You need to create Custom Control
that accepts the url as the parameter and renders the page. This is bit
complex in nature.
 
G

Guest

I've seen where it's easy in Sharepoint, but that isn't an option. I need to
use ASP .Net but I'm not sure how to do it in ASP .Net 2.0. Any suggestions
on where to begin? I've looked at a few things (user control, web control,
web part) but I can't see how to make a control that would render an ASP
page. If you think it's possible I could use at least some high level
suggestions.
 
J

John Timney \(MVP\)

Yeah - its pretty difficult without frames. Perhaps you should just use an
iFrame or a popup window and load that using javascript with the correct
URL's. Technically, thats all athe sharepoint PageViewerWebPart really
does.

The alternative would be to use the network classes to get the html from a
remote asp call and load that into your page. You'll need to strip out the
head details, and you may have problems with styles - but you can get it to
work depending on how complex your asp page is, its just a bit of work for
the return. Its easy enough to render that into a panel

--
Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
 
M

Mark Rae

I'm starting to think that this just isn't possible without frames.

Is there any particular reason you don't want to use an <iframe>? Seems like
the perfect solution here...
 
G

Guest

The main reason for not wanting to use <iframe> is to do the right thing.
Everything I read on the subject thus far implied that not only does
Microsoft want you to stop using frames with Visual Studio 2005, but the
developer community also seemed to agree it was well past time to do so.

But, I might look into it just to see if it causes more problems that it
solves. I had hoped that since this can be done in Sharepoint it would be
possible to port the web part to ASP .Net.
 
L

Laurent Bugnion [MVP]

Hi,
The main reason for not wanting to use <iframe> is to do the right thing.
Everything I read on the subject thus far implied that not only does
Microsoft want you to stop using frames with Visual Studio 2005, but the
developer community also seemed to agree it was well past time to do so.

You are confusing frames and IFRAME. An IFRAME is quite OK to display
external content in a given webpage, in fact it's often the only way.

The alternative would be to load the ASP page on the server using a
HttpWebRequest object
(http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.aspx)
and then parse the HTML code and add it into your ASPX page. It's doable
and would be cleaner.
But, I might look into it just to see if it causes more problems that it
solves. I had hoped that since this can be done in Sharepoint it would be
possible to port the web part to ASP .Net.

HTH,
Laurent
 
M

Mark Rae

You are confusing frames and IFRAME. An IFRAME is quite OK to display
external content in a given webpage, in fact it's often the only way.
Definitely!

The alternative would be to load the ASP page on the server using a
HttpWebRequest object
(http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.aspx)
and then parse the HTML code and add it into your ASPX page. It's doable
and would be cleaner.

That would be fine for the pure HTML, but what about images, CSS etc...?
 
L

Laurent Bugnion [MVP]

Hi,

Mark said:
That would be fine for the pure HTML, but what about images, CSS etc...?

CSS and JavaScript code added in the HEAD section has to be parsed from
the ASP page and added to the ASPX page's HEAD. CSS code inline can
simply be added as-is. External files (JavaScript, CSS, images) can be
left on the original server, and the reference to them parsed and added
to the ASPX page as-is, since there is nothing preventing the call to a
3rd party server to be done for these elements.

Doable doesn't mean easy, but it can be done :)

Greetings,
Laurent
 
G

Guest

Perhaps you're correct and in my searches I was confusing IFrame and frames.
I was also thrown by the fact that IFrames is not on the toolbar for VS 2005,
which usually means it's not recommended.

I did a quick test with an <iframe> and it worked with 5 minutes. I'm not
sure it will work with master pages as easily, or if there will be any other
issues, but it's good so far. I would prefer something like the web part for
SharePoint but it's better than nothing.

Thanks for the help.

Laurent Bugnion said:
Hi,
The main reason for not wanting to use <iframe> is to do the right thing.
Everything I read on the subject thus far implied that not only does
Microsoft want you to stop using frames with Visual Studio 2005, but the
developer community also seemed to agree it was well past time to do so.

You are confusing frames and IFRAME. An IFRAME is quite OK to display
external content in a given webpage, in fact it's often the only way.

The alternative would be to load the ASP page on the server using a
HttpWebRequest object
(http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.aspx)
and then parse the HTML code and add it into your ASPX page. It's doable
and would be cleaner.
But, I might look into it just to see if it causes more problems that it
solves. I had hoped that since this can be done in Sharepoint it would be
possible to port the web part to ASP .Net.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 

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