webbrowser, programmatically clicking javascript dropdown-box

Kitesurfer

New member
Joined
Jan 9, 2015
Messages
2
Programming Experience
10+
I'm showing a URL on a form via VB.NET's Webbrowser object. On the website is a dropdown-box ... when I manually select another entry in the dropdown-box, the URL of the website doesn't change, but other information is then shown in the webbrowser-object.
When I save the site in a html-file I see that it's done via javascript (see below the piece of html-code where the dropdown is handled).

What I want to do in VB.NET ... is after the URL is ready loading, programmatically in VB.NET select another entry from the dropdown-box. How do I do that ?

VB.NET:
                    <select name="ctl00$MainContent$ddlPeriode" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$ddlPeriode\',\'\')', 
0)" id="MainContent_ddlPeriode" class="periode">
  <option value="1">Specifiek</option>
  <option value="2">Vandaag</option>
  <option selected="selected" value="3">Afgelopen 14 dagen</option>
  <option value="4">Maand</option>
  <option value="5">Kwartaal</option>
  <option value="6">1 jaar</option>
  <option value="7">2 jaar</option>
  <option value="8">5 jaar</option>
  <option value="9">10 jaar</option>
  <option value="10">15 jaar</option>
 </select>
 
VB.NET:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]WebBrowser.Document.GetElementById(
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"MainContent_ddlPeriode"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]).SetAttribute([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"value"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"6"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2])

does the trick. The element is selected ... but the next problem arises. Nothing happens, it looks like the onchange-event is not triggered.
Does anyone know how to make this work ? ... thanks.[/SIZE][/FONT][/SIZE][/FONT]
 

Latest posts

Back
Top