Ahmed
Ahmed

Reputation: 135

How to add a hyperlink in a text file in ASP.NET using VB

I have tow pages, first one for displaying the data in the text file and the other one is to store the data. I want to save a site in the text file but when i display the data will be just text and I can't click it as a link. The code I post is when I write to a file in display page.

    Try
        Dim fs As String
        fs = Server.MapPath("Footer.txt")
        lblsplittext.Text = ""
        Dim filestream As StreamReader 
        filestream = New IO.StreamReader(fs)
        Dim readcontents As String = filestream.ReadToEnd()
        Dim textdelimiter As String = "#"
        Dim splitout = Split(readcontents, textdelimiter)
        Dim i As Integer
        For i = 0 To UBound(splitout)
            lblsplittext.Text &= splitout(i) & "<br>"
        Next
        filestream.Close()
    Catch ex As Exception

        Dim str As String
        str = ex.Message

    End Try

If you have a different suggestion about how to read from a file or database (it doesnt matter from where for now) just keep in mine when i display them i just need to have hyperlinks among my text... Or can I write to html file instead of text file if so what is the difference i need to make to write to html. I really really need help here and i have done many searches but i found nothing. Thanks in advance.

Upvotes: 1

Views: 1205

Answers (1)

Ann L.
Ann L.

Reputation: 13965

There are a number of ways you could do this. One would be to use a series of dynamically-added Label controls. Your Hyperlink control could simply be inserted between one Label control and the next.

Do you intend to retrieve information from your series of labels on postback? (It would be redundant to do that, since you already know what the information is, but just in case.) Using multiple controls would make that more complicated. You could try one or more Literal controls, created dynamically and added as child controls to a Panel control. Again, the Hyperlink control would be added at whatever time you need it.

Upvotes: 3

Related Questions