如何让WebBrowser解析我给的html源代码 我的这个源代码放在了字符串String html里了~怎么让WebBrowser控件解析我提供的这个html源代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 webBrowser1.DocumentText = "<html><body>Please enter your name:<br/>" + "<input type='text' name='userName'/><br/>" + "<a href='http://www.microsoft.com'>continue</a>" + "</body></html>"; 如果要使用字符串处理工具操作显示在 WebBrowser 控件中的 HTML 页的内容,则使用该属性。例如,可以使用该属性从数据库加载页,也可以使用正则表达式分析页。设置该属性时,WebBrowser 控件在加载指定文本之前,自动导航到 about:blank URL。这意味着设置该属性时,发生 Navigating、Navigated 和 DocumentCompleted 事件,且 Url 属性的值不再有意义。若要将网页的内容作为 Stream 访问,请使用 DocumentStream 属性。也可以通过 Document 属性,使用 HTML 文档对象模型 (DOM) 访问页内容。下面的代码示例演示如何使用 DocumentText 属性以编程方式显示选择的文档内容。此示例要求窗体包含一个名为 webBrowser1 的 WebBrowser 控件。private void Form1_Load(object sender, EventArgs e){ webBrowser1.DocumentText = "<html><body>Please enter your name:<br/>" + "<input type='text' name='userName'/><br/>" + "<a href='http://www.microsoft.com'>continue</a>" + "</body></html>"; webBrowser1.Navigating += new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);}private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e){ System.Windows.Forms.HtmlDocument document = this.webBrowser1.Document; if (document != null && document.All["userName"] != null && String.IsNullOrEmpty( document.All["userName"].GetAttribute("value"))) { e.Cancel = true; System.Windows.Forms.MessageBox.Show( "You must enter your name before you can navigate to " + e.Url.ToString()); }} DevExpress.XtraGrid.GridControl手动添加行的问题 c# Access 为什么保存不了数据 如何在winform中动态添加或删除控件 关于asp.net 上传后需要修改某个文件的问题!(这高手多,请赐教)在线等~~~~ 不太明白:" .NET 框架类库" 帮助之 "线程安全" 的具体含义 C# execl导入access等待提示窗口 求给个解决思路 C#泛型类型转换问题 请教STRING的问题 还是 SendMessage() ? c# 请问哪位用过Bluetooth Framework VCL里面的bftowdthunk.dll这个组件
"<html><body>Please enter your name:<br/>" +
"<input type='text' name='userName'/><br/>" +
"<a href='http://www.microsoft.com'>continue</a>" +
"</body></html>";
下面的代码示例演示如何使用 DocumentText 属性以编程方式显示选择的文档内容。此示例要求窗体包含一个名为 webBrowser1 的 WebBrowser 控件。
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.DocumentText =
"<html><body>Please enter your name:<br/>" +
"<input type='text' name='userName'/><br/>" +
"<a href='http://www.microsoft.com'>continue</a>" +
"</body></html>";
webBrowser1.Navigating +=
new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
}private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
System.Windows.Forms.HtmlDocument document =
this.webBrowser1.Document; if (document != null && document.All["userName"] != null &&
String.IsNullOrEmpty(
document.All["userName"].GetAttribute("value")))
{
e.Cancel = true;
System.Windows.Forms.MessageBox.Show(
"You must enter your name before you can navigate to " +
e.Url.ToString());
}
}