Including an .ASPX page within another .ASPX Page?
I have an old ASP application that I am converting to .Net. One of my issues is that in the old ASP app, their was a page that had a statement like this: <!--#Include file='topNav.asp'-->. Now I know all this does is insert this other ASP page in a particular location within the current page. By the way, this page is a navigation page that displays a horizontal menu.
So, my question is, how can I incorporate this same page within a new ASPX page. I was told one way would be to create a UserControl but I'm not sure how to do that. I'm looking for other possibilities before resorting to UC.
Thanks,
Re: Including an .ASPX page within another .ASPX Page?
Sounds to me like you're wanting a MasterPage for the header & menu and whatnot, then a ContentPage for each actual page.
You can make the header and menu as a control, but I would still use a MasterPage to bring it all together.
Re: Including an .ASPX page within another .ASPX Page?
Re: Including an .ASPX page within another .ASPX Page?
While I agree with JBs suggestion that you rewrite this using a master Page, you might find that an IFrame provides a quicker, dirtier solution. It basically just lets you host one page inside another so you could just add it to your new page and drop your menu page straight into it. You can't communicate between the pages, though, so it's not suitable to all scenarios.
Re: Including an .ASPX page within another .ASPX Page?
Quote:
Originally Posted by
FunkyDexter
You can't communicate between the pages, though, so it's not suitable to all scenarios.
This is not "strictly" true. If required, and assuming the pages were coming from the same server, use JavaScript to call into the parent page, from the page within the iFrame. This is even more "dirty", but is possible :)
Gary
Re: Including an .ASPX page within another .ASPX Page?
Quote:
Originally Posted by
FunkyDexter
While I agree with JBs suggestion that you rewrite this using a master Page, you might find that an IFrame provides a quicker, dirtier solution. It basically just lets you host one page inside another so you could just add it to your new page and drop your menu page straight into it. You can't communicate between the pages, though, so it's not suitable to all scenarios.
Quote:
Originally Posted by
gep13
This is not "strictly" true. If required, and assuming the pages were coming from the same server, use JavaScript to call into the parent page, from the page within the iFrame. This is even more "dirty", but is possible :)
Gary
In my personal opinion, the iFrame used to serve a really good purpose in the early days of the web though using JS to build a url string to pass parameters to the iFrame page is much more of a pain than I would care to deal with.
These days, at least with .Net, there are far more options to handle this kind of scenario and everything I would use an iFrame in the classic asp days I can replace with a MasterPage/ContentPage ideology. In the long run I find it to be a much cleaner solution and is far easier to keep track of and maintain. Just my 2 cents.
Re: Including an .ASPX page within another .ASPX Page?
Quote:
Originally Posted by
JuggaloBrotha
In my personal opinion, the iFrame used to serve a really good purpose in the early days of the web though using JS to build a url string to pass parameters to the iFrame page is much more of a pain than I would care to deal with.
These days, at least with .Net, there are far more options to handle this kind of scenario and everything I would use an iFrame in the classic asp days I can replace with a MasterPage/ContentPage ideology. In the long run I find it to be a much cleaner solution and is far easier to keep track of and maintain. Just my 2 cents.
I don't disagree. The only reason that I would continue to suggest an iFrame, in this case, is because the page already exists, and can be used as is. Implementing the Master/Content Pages, although the "correct" approach, would involve a lot of effort, which the OP might not have. In which case, an interim step of using an iFrame might be required.
Gary
Re: Including an .ASPX page within another .ASPX Page?
And neither do I:) I was really just throwing out the quick and dirty alternative.
Quote:
This is not "strictly" true.
I did try that on a recent project I inherited which has an IFrame in it. I basically wanted to push a button in the iframe page when a button was pushed in the main page. It was a total nightmare and I eventually gave up and went a different route. I figured saying that it was impossible was close enough to be true to be useful.