How do I change a dropdown box in a webbrowser control?

前端 未结 2 2012
终归单人心
终归单人心 2020-12-18 09:49

So I have a listbox I want to change, that looks like this:

\"enter

How do I c

2条回答
  •  感情败类
    2020-12-18 10:19

    I'm a bit confused about your question. If you just want to alter an element in the HTML, Jeremy's answer is the best, and simplest, way to go. If you wanted to call the document's javascript, this should work:

    Let's assume that the webbrowser's document contains the following HTML:

    
        
        Invoke Test
        
        
            
    Waiting...

    To invoke the webbrowser document's javascript method, you can use something like this:

    private void button1_Click(object sender, EventArgs e)
    {
        object o = webBrowser1.Document.InvokeScript("changeDate('june')");
    }
    

    No System.Web, ASP, ScriptManagers or Interop are needed. All the tools you need to control webbrowser and document objects and events come with the webbrowser control.

提交回复
热议问题