Results 1 to 8 of 8

Thread: Including an .ASPX page within another .ASPX Page?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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,
    Blake

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Including an .ASPX page within another .ASPX Page?

    Ok, thanks for the tip!
    Blake

  4. #4
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    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.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Including an .ASPX page within another .ASPX Page?

    Quote Originally Posted by FunkyDexter View Post
    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

  6. #6
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Including an .ASPX page within another .ASPX Page?

    Quote Originally Posted by FunkyDexter View Post
    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 View Post
    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.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Including an .ASPX page within another .ASPX Page?

    Quote Originally Posted by JuggaloBrotha View Post
    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

  8. #8
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: Including an .ASPX page within another .ASPX Page?

    I don't disagree
    And neither do I I was really just throwing out the quick and dirty alternative.

    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.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width