如何在ASP.net中使用WebBrowser? [英] How do I can use a WebBrowser in ASP.net ?

查看:165
本文介绍了如何在ASP.net中使用WebBrowser?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我使用带有Windows窗体应用程序的webBrowser从网站上检索产品的价格



我的代码是如下所示:

Hello everyone !
I used webBrowser with windows form application to retrieve a price of a product from a website

my code is as following:

 public Form1()
       {
           InitializeComponent();



           webBrowser1.Navigate(" http://www.wine-searcher.com/wine-valuation-f.lml");
              webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);


       } 

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
       {

           webBrowser1.Document.GetElementById("wn1_input").InnerText = "William Fevre Les Clos, Chablis Grand Cru, France";
           webBrowser1.Document.GetElementById("vt1_input").InnerText = "NV";
           webBrowser1.Document.GetElementById("valButton").InvokeMember("click");
           textBox1.Text = webBrowser1.Document.GetElementById("value1").InnerHtml;
 }



我想在aspx页面中使用相同的代码但是当我创建我的webbrowser时它给了我一个例外!


I want to use the same code in aspx page but it gives me an exception when I'm creating my webbrowser !

推荐答案

您不能在ASP.NET应用程序中使用WebBrowser控件。它取决于被放在Windows窗体上,您也无法在ASP.NET应用程序中使用。
You cannot use a WebBrowser control in a ASP.NET application. It depends on being dropped on a Windows Form, which you also cannot use in a ASP.NET application.


请再次检查您的要求。有些事情已经完成,而不是为了所有事情。



WebBrowser 控件仅在Windows窗体中可用。顺便说一句,在Web应用程序中,您已经拥有了用户的Web浏览器,您的所有HTML都会被呈现。



现在,查看您的代码,看起来像你试图在某些控件中设置一些值。您可以使用 JavaScript 轻松完成此操作。我想你在某些方面感到困惑。
Please review your requirements once again. Something is done for something, not for everything.

WebBrowser Control is only available in Windows Forms. By the way, in web applications, you already have the User's Web Browser, where all your HTML gets rendered.

Now, looking at your code, it seems like you are trying to set some values in some controls. You can easily do this using JavaScript. I guess you are confused at some point.


这篇关于如何在ASP.net中使用WebBrowser?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆