So I have a listbox I want to change, that looks like this:
How do I c
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:
<html>
<head>
<title>Invoke Test</title>
</head>
<body>
<div id="testdiv">Waiting...</div>
<script>
function changeDate(date) {
var x=document.getElementById("testdiv");
x.innerHTML = date;
}
</script>
</body>
</html>
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.
View the HTML of the website and identify the id and values of the dropdownlist, for example:
<select id="bdayMonthId" size="1" name="bdayMonth">
<option value="">Month</>
<option value="Jan">January</>
<option value="Feb">February</>
<option value="Mar">March</>
</select>
To pre-select the dropdownlist value in the WebBrowser control use this Winform code:
webBrowser1.Document.GetElementById("bdayMonthId").SetAttribute("value", "Feb");