Use of the C#webbroswer control

Source: Internet
Author: User

In Webbroswer, you can embed a Web page file that is bound by a URL property.

A URI, Uniform Resource Identifier, used to uniquely identify a resource.

URL, a Uniform Resource locator, which is a specific URI that a URL can use to identify a resource.

It contains information that indicates the location of the file and how to handle it.

The protocols that can be processed include: Http,https,ftp,mailto,ldap,file,news,gopher,telnet.

It should also be possible to only try HTTP and File,https in Webbroswer in the form of HTTP encryption.

HTTP is a hyperlink form, which is a link on the web.

File is the form of local files that can display a local HTML file in the Webbroswer.

1.WebBroswer can monitor Web page load Complete event, documentcompleted event.

2. Monitor the element document.getElementById ("id") on the Web page;

3. Monitor element related events, such as monitoring click events. Htmlelement.click+=htmlelement_click; Register a Click event

4. Execute JavaScript code, String msg=document.invokescript ("Demofuc", New string[]{"Demo"}) as String;

Where MSG is the data returned by the JS code, here is the string type of data, if JS returns an object, the foreground receives a COM type object, currently does not handle

Demofunc the name of a method that is well defined for JS

If there are parameters that need to be transferred in a object[] way, to actually get only the value of the first element

5. Can get information about trigger object when triggering event

private void Btn_click (object sender, HtmlElementEventArgs e)
{
HtmlElement msgbtn = sender as htmlelement;//convert sender to HtmlElement type
if (gohomemsgbtn.id = = "... ")//Get the ID of the element
{


}

}

string Path =string": /.. /demo.html"new uri" (new uri (path), URI),//concatenation URI, and assign value to Webbroswer

Use of the C#webbroswer control

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.