Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# web browser select list item click

I am trying to select item from select list box using this method:

  var elements = webBrowser1.Document.GetElementsByTagName("select");



        foreach (HtmlElement element in elements)
        {

            if (element.GetAttribute("id")=="pagesize")
            {
                element.GetElementsByTagName("option")[2].SetAttribute("selected", "selected");
                webBrowser1.Document.InvokeMember("click");
            }
        }

from this html code

<select name="pagesize" id="pagesize" onchange="changeFileListRequestSize();">
                <option value="10">10 files per page</option>
                <option value="25" selected="selected">25 files per page</option>
                <option value="50">50 files per page</option>
                <option value="100">100 files per page</option>
                <option value="200">200 files per page</option>
            </select>

item is actually changes but that's doesn't execute onchange="changeFileListRequestSize();" javascript event.

how to simulate select list item click or "change"

like image 240
dovydas juraska Avatar asked Oct 13 '12 17:10

dovydas juraska


1 Answers

document.GetElementById("pageSize").InvokeMember("onchange")
like image 189
aliassce Avatar answered Oct 03 '22 05:10

aliassce