2

I'm developing an app in C# for mac osx (using monomac).. In my app I have a webview that loads a webpage that contains some inputs, one of those inputs is a combobox..

The thing is, I need to get the selected value of the combobox, but I don't know how can I do that in c#..

First I used the GetElementById to get a DomElement that represents the combobox (select) that I want, this is working properly.. This is part of my C# code

DomElement comboBox = this.htmlDocument.GetElementById(id);
if(comboBox == null) throw new Exception("ComboBox (" + id + ") could not be found");

The problem is, now that I have the DomElement of my combobox, I can't find a way to get the selected value.. In javascript this would be easy, as I would do something like the solution of that question-> Get selected value in dropdown list using JavaScript?)

var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].value;

The problem is I can't find a way to do this in C#, I'm no DOM expert, so my knowlegde is limited, but i've tried several things, like iterate all element attributes to see if there was a 'selectedIndex' or something related, I also tried to get the comboBox.Value property, but it returns an empty string, so, again, no luck..

So if anyone knows how can I do this, I would appreciate..

Community
  • 1
  • 1
BraCa
  • 351
  • 1
  • 5
  • 13

0 Answers0