|
-
Jul 20th, 2007, 10:48 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] WebBrowser1.DocumentText = ???
I've put my HTML into an array then did the following:
Code:
Dim j As Integer
WebBrowser1.DocumentText = ""
While arrCard(j) <> "+++END+++"
'objStreamWriter.WriteLine(arrCard(j))
WebBrowser1.DocumentText += arrCard(j)
j += 1
End While
WebBrowser1.Update()
However, nothing happens in the WebBrowser1 control. DocumentText still says "<HTML></HTML> rather than the code I just gave it. It doesn't display the HTML. The only way I can get it to display anything is if I set the URL to a file before I run the program.
Any ideas?
-
Jul 20th, 2007, 10:57 AM
#2
Re: WebBrowser1.DocumentText = ???
Try putting your HTML into a string variable inside of your loop and then set your WebBrowser's DocumentText to that string after the loop.
For example
vb.net Code:
' Put HTML in my WebBrowser.
Dim s As String = String.Empty
For i As Integer = 0 To 10
s += "Hi"
Next i
Me.WebBrowser1.DocumentText = s
-
Jul 20th, 2007, 11:06 AM
#3
Re: WebBrowser1.DocumentText = ???
Without seeing the original text it's hard to say for sure but there's probably a better way of assigning the content rather than looping through.
Out of interest, how does the text get placed into an array in the first place? Where does it originate from?
-
Jul 20th, 2007, 01:08 PM
#4
Thread Starter
Fanatic Member
Re: WebBrowser1.DocumentText = ???
The array gets built as such:
Code:
arrCard(i) = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"
i += 1
arrCard(i) = "<html xmlns='http://www.w3.org/1999/xhtml'>"
i += 1
arrCard(i) = "<head>"
nmadd: I tried that and it didn't work.
-
Jul 20th, 2007, 01:16 PM
#5
Re: WebBrowser1.DocumentText = ???
Can you post a link to the html file that it's taken from?
What I really mean is that if there's a html document out there and you are feeding it 1 line at a time by hand then you might simply be able to create your array very easily by splitting by new line so you could avoid all that repetition. I mean, how long does that code go on for? If it was a large page i would imagine a great deal longer...
Maybe use a WebClient to download the string, parse the file and then simply loop the array. Just trying to find out about the background of it.
-
Jul 20th, 2007, 01:21 PM
#6
Re: WebBrowser1.DocumentText = ???
Really? Because I can get something like this to work:
vb.net Code:
' Fill my WebBrowser.
Dim s As String = String.Empty
For i As Integer = 0 To 100
s += ary(i)
Next i
Me.WebBrowser1.DocumentText = s
but not this:
vb.net Code:
' Fill my WebBrowser.
Dim s As String = String.Empty
For i As Integer = 0 To 100
Me.WebBrowser1.DocumentText += ary(i)
Next i
-
Jul 20th, 2007, 01:56 PM
#7
Thread Starter
Fanatic Member
Re: WebBrowser1.DocumentText = ???
stimbo: it's not a file. I'm building the HTML in that array.
nmadd: i hear the internet explorer "click" noise, but that's it. the page stays blank and documentext still = "<HTML></HTML>"
-
Jul 20th, 2007, 02:07 PM
#8
Re: WebBrowser1.DocumentText = ???
Without checking if the content is okay this works perfectly for me:
vb Code:
Dim arrCard(8) As String
Dim i As Integer = 0
arrCard(i) = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"
i += 1
arrCard(i) = "<html xmlns='http://www.w3.org/1999/xhtml'>"
i += 1
arrCard(i) = "<head>"
i += 1
arrCard(i) = "<meta http-equiv=" & "Content-Type" & "content=" & "text/html; charset=ISO-8859-1" & "/>"
i += 1
arrCard(i) = "</head>"
i += 1
arrCard(i) = "<body>"
i += 1
arrCard(i) = "<P>My content <br> Really </P>"
i += 1
arrCard(i) = "</body>"
i += 1
arrCard(i) = "</html>"
Dim totalContent As String = Nothing
For j As Integer = 0 To arrCard.Length - 1
totalContent &= arrCard(j)
Next
Me.WebBrowser1.DocumentText = totalContent
Set break points and start stepping through your code and find out where the problem is.
-
Jul 20th, 2007, 02:16 PM
#9
Re: WebBrowser1.DocumentText = ???
Nuts. I just typed a whole thing up too.
I'm not sure why your HTML is like this but it works fine here too.
-
Jul 20th, 2007, 03:07 PM
#10
Thread Starter
Fanatic Member
Re: WebBrowser1.DocumentText = ???
I deleted my WebBrowser1 control and re-added it. It works now.
-
Jul 20th, 2007, 03:10 PM
#11
Re: WebBrowser1.DocumentText = ???
Glad you got it working. Now you can mark this thread as "Resolved" and let everybody know.
-
Jul 20th, 2007, 03:19 PM
#12
Thread Starter
Fanatic Member
Re: [RESOLVED] WebBrowser1.DocumentText = ???
Done. Thanks guys for your help in troubleshooting.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|