| |

VerySource

 Forgot password?
 Register
Search
View: 706|Reply: 4

*** c # question * How do you write data to the form in webBrowser, seniors ???

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-8 21:00:01
| Show all posts |Read mode
You seniors just learned c #, I want to write data to the form in webBrowser how to write ???
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-30 11:15:01
| Show all posts
namespace WindowsApplication3
{
    public partial class Form1: Form
    {
        public Form1 ()
        {
            InitializeComponent ();
        }

        private void Form1_Load (object sender, EventArgs e)
        {
            webBrowser1.Navigate ("http://www.baidu.com");
        }

        private void webBrowser1_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            webBrowser1.Document.Forms [0] .Children ["wd"]. SetAttribute ("value", "test");
        }
    }
}
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-5-30 11:30:01
| Show all posts
HtmlDocument htmlDoc = webBrowser1.Document;
            HtmlElement txtName = htmlDoc.All ("member");
            HtmlElement txtPass = htmlDoc.All ["Password"];
            HtmlElement btnLogin = htmlDoc.All ["Enter"];

            if (txtName == null || txtPass == null || btnLogin == null)
                return;

            txtName.SetAttribute ("value", "123456");
            txtPass.SetAttribute ("value", "123456");
            btnLogin.InvokeMember ("Click");


.NET 2.0 support
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-5-30 15:45:01
| Show all posts
It should be possible through webBrowser.Document
After webBrowser.Document.GetElementById () or webBrowser.Document.GetElementByTagName () (Index) gets the object, assign it a value.
In short, study the related methods of webBrowser.Document. *!
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-5-30 23:00:01
| Show all posts
Okay, thank you all!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list