<txt src= ...> equivalent of <img src= ...>

Discussion in 'ASP .Net' started by Steve Richter, Feb 8, 2006.

  1. Is there a way to pull text from a url into a web page? Similar to how
    the <img> element uses a URL to access the image to display.
    <txt src="http:\\www....." >

    thanks,

    -Steve
     
    Steve Richter, Feb 8, 2006
    #1
    1. Advertising

  2. Hi Steve,

    This feels like a hack but it does accomplish what you want.

    It uses WebClient to fetch the file as a string. (This is ASP.NET 2.0 code)

    Perhaps this will spark someone to come up with a more elegant solution?

    Ken
    Microsoft MVP [ASP.NET]

    <%@ Page Language="VB" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
    Protected Sub Page_Load _
    (ByVal sender As Object, _
    ByVal e As System.EventArgs)
    Dim wc As New System.Net.WebClient
    Dim sb As New StringBuilder
    sb.Append(wc.DownloadString("http://www.kencox.ca/textfile.txt"))
    Literal1.Text = sb.ToString
    End Sub
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Webclient Text</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:literal id="Literal1" text="" runat="server"></asp:literal>
    </div>
    </form>
    </body>
    </html>

    "Steve Richter" <> wrote in message
    news:...
    > Is there a way to pull text from a url into a web page? Similar to how
    > the <img> element uses a URL to access the image to display.
    > <txt src="http:\\www....." >
    >
    > thanks,
    >
    > -Steve
    >
     
    Ken Cox - Microsoft MVP, Feb 8, 2006
    #2
    1. Advertising

  3. IFrame.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    We got a sick zebra a hat,
    you ultimate tuna.


    "Steve Richter" <> wrote in message
    news:...
    > Is there a way to pull text from a url into a web page? Similar to how
    > the <img> element uses a URL to access the image to display.
    > <txt src="http:\\www....." >
    >
    > thanks,
    >
    > -Steve
    >
     
    Kevin Spencer, Feb 8, 2006
    #3
  4. Hi,

    Steve Richter wrote:
    > Is there a way to pull text from a url into a web page? Similar to how
    > the <img> element uses a URL to access the image to display.
    > <txt src="http:\\www....." >
    >
    > thanks,
    >
    > -Steve


    The best (IMHO) and cleanest way is to use a XmlHttp object to send a
    GET request for the text file, and then use the callback mechanism to
    include it in your HTML document using DOM.

    For more info, check XmlHttp on Google, and remember that you can also
    use this object client-side with JavaScript (this is what is used to
    make WebServices work)

    HTH,
    Laurent
    --
    Laurent Bugnion, GalaSoft
    Software engineering: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch
     
    Laurent Bugnion, Feb 9, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.austin.rr.com

    how to download img from html img tag

    news.austin.rr.com, Apr 27, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    514
    Steve C. Orr [MVP, MCSD]
    Apr 27, 2005
  2. Philipp Lenssen

    Problem: <img></img>

    Philipp Lenssen, Jun 27, 2005, in forum: XML
    Replies:
    15
    Views:
    766
    David Håsäther
    Jul 3, 2005
  3. pheadxdll
    Replies:
    16
    Views:
    3,700
    Neredbojias
    Jun 6, 2007
  4. Jopek
    Replies:
    7
    Views:
    404
    dorayme
    Apr 26, 2009
  5. Hugh Newbury

    Txt function like <IMG SRC> ?

    Hugh Newbury, Nov 11, 2012, in forum: HTML
    Replies:
    12
    Views:
    740
    Ray_Net
    Nov 13, 2012
Loading...

Share This Page