[英]C# WebBrowser control not displaying custom HTML
I have a web browser control that for some reason isn't loading my HTML: 我有一个网络浏览器控件,由于某种原因无法加载我的HTML:
string updatingChatHTML = ""
+ "<HTML> "
+ "<head>"
+ "<style>"
+ "body {"
+ " margin: 0px;"
+ " padding: 0px;"
+ " background: " + chatBackground + ";\n"
+ " Font-Family: Arial;"
+ " font-size: 11px; "
+ " text-align: left;"
+ "}"
+ "</style>"
+ "</head>"
+ "<body>";
txtChat.DocumentText = updatingChatHTML + "</body></HTML>";
(txtChat is my WebBrowser Control). (txtChat是我的WebBrowser控件)。
The weird thing is, it was working before I changed something, but I can't figure out what I changed that caused it to stop working. 奇怪的是,在我更改某些东西之前它一直在工作,但是我无法弄清楚导致它停止工作的更改。
I have a breakpoint set to just after the last line above, and I can see that updatingChatHTML has the proper value it's meant to, but txtChat.DocumentText still has a value of <HTML></HTML>\\0
. 我在上面的最后一行之后设置了一个断点,并且可以看到updateChatHTML的含义正确,但是txtChat.DocumentText的值仍然为<HTML></HTML>\\0
。
I thought maybe it was an initialisation thing, so I added txtChat.Navigate("about:blank");
我以为这可能是初始化的东西,所以我添加了txtChat.Navigate("about:blank");
prior to any assignment, but it still doesn't work. 在进行任何分配之前,但仍然无法正常工作。
This event actually gets fired quite often though, and the first time/two times, it doesn't work, but after the form is finished loading it seems to, but it's already the last thing to happen on my Form_Load. 实际上,此事件实际上经常被触发,并且第一次/两次都不会起作用,但是在表单加载完成后,它似乎可以启动,但这已经是我的Form_Load上发生的最后一件事。
Any suggestions? 有什么建议么?
Attempting to set the DocumentText
property when 尝试在以下情况下设置DocumentText
属性
will cause the property assignment to fail silently. 将导致属性分配静默失败。
After calling the Navigate
function you should monitor the DocumentCompleted
event for notification of when the navigation operation completes. 调用Navigate
功能后,您应该监视DocumentCompleted
事件,以获取有关导航操作何时完成的通知。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.