SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ASP page inside ASPX page = possible?

    Is there a way to insert an .asp page into a .aspx page? I am trying to integrate a table from the asp page into the current aspx conversion of a mobile site. I am new to ASP and .NET; therefore, I am seeking ways to start.

    Thank you in advance for your help.

  2. #2
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    how about having that in an iframe.

  3. #3
    SitePoint Member
    Join Date
    May 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, that is interesting. I could see that maybe working; however, iframes don't meet code standards anymore, so I want to ensure I am keeping current. However, thank you for this idea.

  4. #4
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by creativeedg10 View Post
    ... however, iframes don't meet code standards anymore ...
    Wasn't it included in HTML5?

  5. #5
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,876
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by creativeedg10 View Post
    Hmm, that is interesting. I could see that maybe working; however, iframes don't meet code standards anymore, so I want to ensure I am keeping current. However, thank you for this idea.
    iframes are definitlely still a standard. If anything asp.old is not a standard anymore. So other that a complete rewrite or iframe, I do not think you have another option. I am not sure if and <!--#include--> would work or not, but it might be worth a shot

  6. #6
    SitePoint Addict
    Join Date
    Feb 2005
    Location
    Clogland
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is one way to go about it, this works by by scraping the content of the ASP page. I'm assuming you are using VB as you are coming from a Classic ASP background.

    Code VBNET:
    Imports System.Web
    Imports System.Net
    Imports System.IO
     
    		''' <summary>
    		''' Scrapes the HTML of the given URL
    		''' </summary>
    		''' <param name="Url">The URL to Scrape</param>
    		''' <returns>A string containg the HTML</returns>
    		Public Shared Function ScreenScrape(ByVal Url As String) As String
    			Dim returnString As String = String.Empty
     
    			Dim response As WebResponse
    			Dim request As WebRequest
     
    			If Url.StartsWith("http://") Then
    				' full URL passed
    				request = HttpWebRequest.Create(Url)
    			Else
    				' Partial Path passed, build the URL
    				Dim Domain As String = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
    				If Not Url.StartsWith("/") Then Url = "/" + Url
    				request = HttpWebRequest.Create("http://" + Domain + Url)
    			End If
     
    			Try
    				response = request.GetResponse()
    				Using sr As New StreamReader(response.GetResponseStream())
    					returnString = sr.ReadToEnd()
    				End Using
     
    			Catch ex As Exception
                   ' if an error is returned, view the HTML source code to see what the exception message is.
    				returnString = String.Format("{0}<p>There was an error retrieving the HTML</p>{0}<!-- {1} -->", Environment.NewLine, ex.Message)
    			End Try
     
    			Return returnString
    		End Function

    Just place a Literal control on the page where you would like to have the injected code and call the function like this:

    Code VBNET:
    Literal1.Text = ScreenScrape("/myPage.asp")

    Edit: Consider caching the output string.
    Last edited by SlitheryImp; Jun 9, 2011 at 00:59. Reason: Added comment about caching


Tags for this Thread

Bookmarks

Posting Permissions

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